Order of Nested For Clauses

matrix = [[1, 2], [3, 4], [5, 6]]

flat = [x for row in matrix for x in row]

Which ordinary nested for loop is this comprehension equivalent to?

A

It has no direct nested-loop equivalent, because comprehensions evaluate their for clauses in reverse.

B
flat = []
for row in matrix:
    for x in row:
        flat.append(x)
C
flat = []
for x in matrix:
    for row in x:
        flat.append(x)
D
flat = []
for x in row:
    for row in matrix:
        flat.append(x)