Enumerate a Python List with a Custom Start Index

Iterate over a list with an index that starts at a custom value (like 5) using Python's built-in enumerate() function with the start parameter.

Easy Python 3.9+ Aug 9, 2026 Lists & loops 15 views 0 copies

Python code

4 lines
Python 3.9+
fruits = ["apple", "banana", "cherry", "date"]

for index, fruit in enumerate(fruits, start=5):
    print(f"{index}: {fruit}")

Output

stdout
5: apple
6: banana
7: cherry
8: date

How it works

The enumerate() built-in returns an enumerate object that yields tuples of (index, item) for each element in the iterable. By default start=0, but passing start=5 shifts the index count to begin at 5. In the loop, tuple unpacking assigns the index to index and the list element to fruit. This avoids manual counter variables and keeps the code readable and Pythonic.

Common mistakes

  • Forgetting the `start` parameter, so indices start at 0 instead of the desired value.
  • Assuming `enumerate()` modifies the original list — it only creates an iterator.
  • Passing a non-integer or negative start without considering the intent.

Variations

  1. Use `for index, fruit in enumerate(fruits):` if you want the default start of 0.
  2. Access the enumerate object manually with `next()` if you need incremental processing.

Real-world use cases

  • Displaying numbered lists in reports where numbering must start at a specific value like 1 instead of 0.
  • Tracking line numbers in log files or data files where the first line is line 1.
  • Adding an offset to array indices when aligning data from different sources that use non-zero-based indexing.

Sponsored

Run this sample

Open the browser IDE to tweak the example and see results without installing anything.

Open editor

More from Lists & loops

Related tutorials and quizzes for this topic.