Back
+10 XP
Concept

Pairing Lists Together (zip)

Loop through two lists side-by-side using `zip()`:

python
names = ["Neo", "Trinity"]
roles = ["The One", "Pilot"]

for name, role in zip(names, roles):
    print(f"{name} is the {role}")

# 64. Pairing Lists Together (zip) Loop through two lists side-by-side using `zip()`: ```python names = ["Neo", "Trinity"] roles = ["The One", "Pilot"] for name, role in zip(names, roles): print(f"{name} is the {role}") ``` Gotcha: `zip()` stops the moment the shortest list runs out.

Checkpoint

If List A has 2 items and List B has 10 items, how many times does `zip(A, B)` loop?

Practice

Zip `users = ["Alice", "Bob"]` and `scores = [100, 95]`. Print each user with their score.

Terminal
01
Tap code blocks below to assemble
Available Blocks