python repeat list elements in an iterator
<p>Is there any way to create an iterator to repeat elements in a list certain times? For example, a list is given:</p>

<pre><code>color = ['r', 'g', 'b']
</code></pre>

<p>Is there a way to create a iterator in form of <code>itertools.repeatlist(color, 7)</code> that can produce the following list?</p>

<pre><code>color_list = ['r', 'g', 'b', 'r', 'g', 'b', 'r']
</code></pre>

<p>Try:</p>

<pre><code>def repeat_list(l, n):
    for i in range(n): yield l[i%len(l)]
</code></pre>

python itertools