How can I rewrite this list comprehension as a for loop?
<p>How can I rewrite this using nested for loops instead of a list comprehension? </p>

<pre><code>final= [[]]  
    for i in array_list:
        final.extend([sublist + [i] for sublist in final])


    return final
</code></pre>

<p>Your solution looks to be a very good <code>for</code> loop one.  A one-liner using <code>itertools</code> is possible, but ugly</p>

<pre><code>list(itertools.chain(list(itertools.combinations(arr, i)) for i in range(len(arr) + 1)))
</code></pre>

<p>EDIT:</p>

<p>Prettier:</p>

<pre><code>list(itertools.chain(*[itertools.combinations(arr, i) for i in range(len(arr)+1)]))
</code></pre>

python