zip()

say it: “ZIP” /ˈzɪp/

Pairs up items from two or more lists so you can loop through them together.

What does zip() do?

zip() pairs up items from two or more lists, first with first, second with second, so you can loop through them together.

names = ["Ana", "Ben"]
scores = [92, 85]
for name, score in zip(names, scores):
    print(name, score)   # Ana 92, Ben 85

Level: Apprentice · More Python terms at this level

Updated