The enumerate() function takes a collection (e.g. list, tuple) and returns it as an enumerate object. The enumerate() function adds a counter as the key of the enumerate object.
In this blog post, you will learn how to use enumerate()
function with a list in Python.
Step 1: Create a list
my_list = [1, 2, 3, 4, 5]
Step 2: Print the list
for i, j in enumerate(my_list): print(i, j)
Output:
0 1
1 2
2 3
3 4
4 5