enumerate() Enumerated iterator
Last updated: 2026-09-22
enumerate() Enumerated iterator
enumerate(iterable, start=0) yields (index, item) pairs, useful in for-loops.
| Category | Built-in Functions |
|---|---|
| Kind | Built-in Function |
| Python Version | all |
📝 Syntax
enumerate(iterable[, start])
⚙️ Parameters
| iterable Required | The iterable to enumerate. |
|---|---|
| start Optional | The starting index.(Default:0) |
Returns:An enumerate iterator yielding (index, item) tuples.
💥 Raises
TypeError— Raised when iterable is not iterable.
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
1 apple
2 banana
🏷️ Related Built-in Functions
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat is the start parameter of enumerate() for?
AIt sets the starting index; enumerate(lst, start=1) counts from 1, useful when you want a 1-based index for display.
QDoes enumerate() return a list?
ANo, it returns an enumerate object (a lazy iterator); when needed, use list(enumerate(lst)) to obtain [(0, 'a'), (1, 'b')].
QHow do I use enumerate in a for loop?
Afor i, item in enumerate(lst): unpacks the index and the element directly — more Pythonic than maintaining a counter variable by hand.
QHow do I iterate two lists while also needing the index?
ACombine with zip: for i, (a, b) in enumerate(zip(x, y)): gives you the index and both elements at once.