Using zip() to Parallel Iterate in Python


Iterate over two lists in parallel.

Source Code

names = ['Alice', 'Bob', 'Charlie']
ages = [24, 30, 28]
for name, age in zip(names, ages):
    print(f"{name} is {age} years old")
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments