Skip to content
dreamcode
dreamcode
Map
Enumerate & zip
Lesson 36 of 77
+15 XP on finish
PYTHON INTERMEDIATEChapter 6 · Comprehensions and data tools

Enumerate and zip

enumerate() yields index-value pairs during iteration. zip() pairs up elements from multiple lists in parallel.

Worked example

How it reads

  • enumerate(names) yields index and value pairs
  • zip(names, scores) pairs up elements from lists in parallel
Cloud tip: zip() stops pairing as soon as the shortest input list is exhausted.
main.py
PYTHON
real Python, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Use zip to pair items with [10, 20, 30] and print a 10, b 20 and c 30 on three lines.

Press Run to check your work.