1# Basic syntax:
2for iteration, item in enumerate(iteratable_object):
3 print(iteration)
4# Where:
5# - item is the current element in the iteratable_object
6# - iteration is the iteration number/count for the current iteration
7
8# Basic syntax using list comprehension:
9[iteration for iteration, item in enumerate(iteratable_object)]
10
11# Example usage:
12your_list = ["a", "b", "c", "d"]
13
14for iteration,item in enumerate(your_list):
15 (iteration, item) # Return tuples of iteration, item
16--> (0, 'a')
17 (1, 'b')
18 (2, 'c')
19 (3, 'd')
20
21[iteration for iteration, item in enumerate(your_list)]
22--> [0, 1, 2, 3]
1for idx, item in enumerate(list):
2 print(item)
3 print('Iteration number: ', idx)