DEV Community

qing
qing

Posted on

TIL: `enumerate()` has a `start` parameter you probably never used (2026)

TIL: enumerate() has a start parameter you probably never used

When iterating over lists in Python, enumerate() is a handy function that returns both the index and value of each item. By default, it starts counting from 0, which is usually what we want. However, there's a lesser-known start parameter that allows us to change the starting index.

Let's take a look at an example:


python
fruits = ['apple', 'banana', 'cherry']
print("Default enumerate():")
for i, fruit in enumerate(fruits):
    print(f"{i}: {fruit}")

print("\nEnumerate with start=1:")
for i, fruit in enumerate(fruits, start=

---

*Follow me on Dev.to for daily Python tips and quick guides!*

---

*💡 Related: **Content Creator Ultimate Bundle (Save 33%)** — $29.99*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)