Short answer: yes, you are right in your understanding .
There is only catch: the way you usually use nested list comprehension in python code should work with multidimensional arrays.
A typical example is working with matrices:
>>> matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> [[el - 1 for el in row] for row in matrix] [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
As you can see, nesting works by working on each dimension of the matrix.
In the above examples, it seems that ySet [the bad name btw, since sets is one of the types provided with python] is just a general counter, which makes it a little harder to keep track of what happens under the hood.
As for your first example:
>>> rows = ([1, 2, 3], [10, 20, 30]) >>> [(min([row[i] for row in rows]),max([row[i] for row in rows])) for i in range(len(rows[0]))] [(1, 10), (2, 20), (3, 30)]
You might want to explore the built-in zip function:
>>> zip(rows[0], rows[1]) [(1, 10), (2, 20), (3, 30)]
or for maximum brevity and elegance:
>>> zip(*rows) [(1, 10), (2, 20), (3, 30)]
NTN!