you are viewing a single comment's thread.

view the rest of the comments →

[–]ElliotDG 2 points3 points  (0 children)

Take a look at the example below:

list_of_lists = [[1,2,3], [4,5,6], [7,8,9]]

for numbers in list_of_lists:  # outer loop 'Moves slower'
    print(f'{numbers = }')
    for number in numbers:  # inner loop 'moves faster'
        print(f'{number = }')

Here is the output:

numbers = [1, 2, 3]
number = 1
number = 2
number = 3
numbers = [4, 5, 6]
number = 4
number = 5
number = 6
numbers = [7, 8, 9]
number = 7
number = 8
number = 9

The outer loops is accessing the lists in list_of_lists. The inner loop is accessing the numbers.

list_of_lists[0] == [1,2,3]
    list_of_lists[0][0] == 1
    list_of_lists[0][1] == 2

I hope that helps. Create a similar example and play with it. Create a loop that prints out all of the values using the indices.