[Python] Iterate over indexes and values with enumerate()

Created on November 30, 2026

enumerate() supplies both the index and the value as you loop through a sequence. By default the counter starts at 0.

colors = ['red', 'green', 'blue']

for index, color in enumerate(colors):
    print(index, color)
0 red
1 green
2 blue

Pass start=1 to number displayed items from 1.

colors = ['red', 'green', 'blue']

for number, color in enumerate(colors, start=1):
    print(number, color)
1 red
2 green
3 blue
Python