← Go Back

How to Iterate Over Multiple Lists in the Same Loop

Using the zip() built-in function:

>>> numbers = [1, 2, 3, 4]
>>> letters = ["a", "b", "c", "d"]
>>> for number, letter in zip(numbers, letters):
... print(number, letter)
...
1 a
2 b
3 c
4 d

This also applies to tuples, dictionaries, and other iterable objects.

lists loops built-ins


🐍 You might also find interesting: