Search notes:

Python: enumerate

enumerate(sequence) returns an iterator that provides tuples with two elements: the position of an element in the sequence (that is: the index) and the corresponding value:
someList = ['foo', 'bar', 'baz']

enumeratedList = enumerate(someList)

print (type(enumeratedList))
# <class 'enumerate'>

for index, element in enumeratedList:
    print("{:d}: {:s}".format(index, element) )
# 0: foo
# 1: bar
# 2: baz
Github repository about-python, path: /builtin-functions/enumerate/demo.py

Providing a start value

When using enumerate, the index starts with 0 by default. It is possible to use the optional argument start = n to change the starting index:
things = [ 'foo', 'bar', 'baz' ]

for index, item in enumerate(things, start = 1):
    print(index, item)
#
#  1 foo
#  2 bar
#  3 baz
Github repository about-python, path: /builtin-functions/enumerate/start-value.py

See also

Using enumerate() in a for loop
Python: Built in functions

Index