← Python Foundations
13 / 27
Lesson 13 — enumerate & zip
Loop smarter
enumerate(items) gives you the position and the value on each turn, so you do not need a separate counter. zip(a, b) walks two lists side by side and hands you one item from each per turn. It stops at the end of the shorter list.
colors = ["red", "green"]
for i, c in enumerate(colors):
print(i, c) # 0 red, then 1 green
Why it matters: pairing related lists (names and scores, questions and answers) is everyday work, and these two keep the loop short and safe.
Want it another way?
Task
Zip names and ages and print each pair as: name age
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.