How to enumerate a range of numbers starting with 1 in Python

Enumerating a range of numbers returns a list of tuples where each tuple contains the position in which the number appears and the number itself, respectively. For example, enumerating the range from 1 to 3 results in [(1, 0), (2, 1), (3, 2)].

Solution for How to enumerate a range of numbers starting with 1 in Python : You can use enumerate() to enumerate a range of numbers Call enumerate(iterable, start) with range(stop) as iterable and 1 as start to return an enumerate object beginning at 1 and ending at stop. Use list(**args) with the enumerate object from the previous step as **args to create a list of the enumerated tuples.


how-to-enumerate-a-range-of-numbers-starting-with-1-in-python