Enumerate Function
Multiple Choice Easy
Question
What does list(enumerate(["a", "b"])) return?
Hint
enumerate adds index to iteration.
Explanation
list(enumerate(["a", "b"])) returns [(0, "a"), (1, "b")]. enumerate pairs each element with its index. Common use: for i, value in enumerate(items): print(i, value). Start from a different number: enumerate(items, start=1). This is the Pythonic way to get both index and value in a loop, replacing manual index tracking.
Related Resources
Related Lessons
- Conditions & Loops
Learn conditions and loops.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.