Review Note

Last Update: 07/10/2024 01:20 PM

Current Deck: Python fundamentals

Published

Currently Published Content


Code
matrix = [[1,2],
[3,4]]

flattened = [
item
for row in matrix
for item in row
]

print(flattened)


Output
Explanation
You can put multiple for loops in a comprehension.
Context
Python

Current Tags:

python_fundamentals

Pending Suggestions


No pending suggestions for this note.