Nested Loops
Nested Loops
Syntax:
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
123
456
789
Example 2: Genera ng all pairs of numbers
In this example, a nested for loop is used to generate all pairs of numbers from
two different lists.
list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']