Nested list comprehension where inner loop range is dependent on outer loop
<p>I am trying to represent the following as a list comprehension:</p>

<pre><code>L = []
for x in range(n):
    for y in range(x):
        L.append( (x, y) )
</code></pre>

<p>I have done nested list comprehension in the more typical matrix scenario where the inner loop range is not dependent on the outer loop.</p>

<p>I have considered there may be solutions in <code>itertools</code>, using <code>product()</code> or <code>chain()</code> but have been unsuccessful there as well.</p>

<p>List comprehensions are designed to make a straightforward translation of that loop possible:</p>

<pre><code>[ (x,y) for x in range(3) for y in range(x) ]
</code></pre>

<p>Is that not what you wanted?</p>

python python-3.x list-comprehension nested-loops