Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

list

We can iterate over the elements of a list. We can also print the whole list at once.


numbers = [101, 2, 3, 42]
for num in numbers:
    print(num)
print(numbers)

Output:

101
2
3
42
[101, 2, 3, 42]