Python Enumerate – Start at 1

Enumerate Start at 1 in Python

In Python, enumerate() takes an iterable and an optional start, as arguments. The value provided to start parameter acts as a starting point for the counter.

To enumerate with a start of 1, pass start=1 to enumerate() function.

Example

In this example, we take a list of strings, and iterate over the enumerated list whose start value is 1.

Python Program

fruits = ['apple', 'banana', 'mango', 'cherry']
for index, fruit in enumerate(fruits, start=1):
    print(index, ':', fruit)
Run Code Copy

Output

1 : apple
2 : banana
3 : mango
4 : cherry

Without start=1, enumerate() function would start its counter at 0.

Summary

In this tutorial of Python Examples, we learned how to call enumerate() with start=1.

Related Tutorials

Code copied to clipboard successfully 👍