tested a list derivation that cannot be run in Python 3. Can Daniel give me an explanation?
-sharp python2
matrix = [[1,2,3],[4,5,6],[7,8,9]]
[x for row in matrix for x in row]
-sharp [1, 2, 3, 4, 5, 6, 7, 8, 9]
[x for x in row for row in matrix]
-sharp [7, 7, 7, 8, 8, 8, 9, 9, 9]
-sharp python3
matrix = [[1,2,3],[4,5,6],[7,8,9]]
[x for row in matrix for x in row]
-sharp [1, 2, 3, 4, 5, 6, 7, 8, 9]
[x for x in row for row in matrix]
-sharp Traceback (most recent call last):
-sharp File "<stdin>", line 1, in <module>
-sharp NameError: name "row" is not defined