← Go Back
This also applies to tuples, dictionaries, and other iterable objects.
How to Iterate Over Multiple Lists in the Same Loop
Using thezip()
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.
🐍 You might also find interesting: