Python | List Comprehension Quiz | Question 6

Last Updated :
Discuss
Comments

What will the following list comprehension output?

matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
flattened = [num for row in matrix for num in row]
 

 [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[1, 2, 3, 4, 5, 6, 7, 8, 9]

 [(1, 2, 3), (4, 5, 6), (7, 8, 9)]

[[1], [2], [3], [4], [5], [6], [7], [8], [9]]

Share your thoughts in the comments