Python - Enumeration
Last Updated: 1641Z 23SEP19 (Created: 1640Z 23SEP19)

Get index and value of elements in an iterable.

Signatures:

enumerate(iterable, start=0)

Examples:

numbers = [45, 22, 14, 65, 97, 72]
for idx, num in enumerate(numbers):
    print('{}: {}'.format(idx, num))


"""
Output:
    0: 45
    1: 22
    2: 14
    3: 65
    4: 97
    5: 72
"""

References:

  1. Python Built-in Functions - Enumerate
  2. Python Interview Tips - Enumerate