Skip to content

Commit e33b534

Browse files
committed
Iterating Over a 2D List (Matrix)
1 parent cdcfdd8 commit e33b534

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

0010-For-Loops/for_loops.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,22 @@
7070
print(f"{COMMENT} - finish")
7171
print("======================================================")
7272

73+
COMMENT = "Iterating Over a 2D List (Matrix)"
7374

75+
print(f"{COMMENT} - start")
76+
print()
77+
78+
MATRIX = [
79+
[1, 2, 3],
80+
[4, 5, 6],
81+
[7, 8, 9]
82+
]
83+
84+
for row in MATRIX:
85+
for column in row:
86+
print(column, end=" ")
87+
print() # New line after each row
7488

89+
print()
90+
print(f"{COMMENT} - finish")
91+
print("======================================================")

0 commit comments

Comments
 (0)