01 / 07
A list inside a list
Table-shaped data is often held as a list with lists inside it — one list per row.
You frequently want to turn that into a single flat list. With for that means looping twice and calling append.
table = [[1, 2], [3, 4]]flat = []for row in table: for x in row: flat.append(x)print(flat)Result
[1, 2, 3, 4]