Converting to a for loop
<p>I'm curious as to how this can be rewritten as a for loop? </p>

<pre><code>def decode (lst):
    i=0
    result=[]
    while i&lt;len(lst):
        result+=([lst[i]]*lst[i+1])
        i+=2
    return(result)
print(decode([4,6,2,1,9,5,5,2,4,2]))
</code></pre>

<p>Loop would look like:</p>

<pre><code>for x in range(0, len(lst), 2):
    result+=(lst[i]*lst[i+1])
</code></pre>

<p>You may also use <a href="http://www.secnetix.de/olli/Python/list_comprehensions.hawk" rel="nofollow">list comprehension</a> and simplify this.</p>

<p>Refer: <a href="https://wiki.python.org/moin/ForLoop" rel="nofollow">For Loop</a></p>

python loops for-loop while-loop