Python nested loops and matrices

A nested loop completes the inner loop for each outer iteration. A matrix can be represented as a list of rows, each of which is another list.

Python
matrix = [[1, 2, 3], [4, 5, 6]]
for row in matrix:
    row_total = 0
    for value in row:
        row_total += value
    print(row_total)
Read the full lesson