The way to understand how the nesting works in the list comprehension:<p><pre><code>   L = []
   for x in X:
       for y in Y:
          L.append(x*y)
</code></pre>
[loops] translate to<p><pre><code>  L = [x*y for x in X for y in Y]
</code></pre>
If you understand the order of the loops in the first code fragment; you should understand the order in the second one -- it is <i>the same order</i>.