what is the function of enumerate in python code example
Example 1: enumerate python
l1 = ['alu','noodles','vada-pav','bhindi']
for index, item in enumerate(l1):
if index %2 == 0:
print(f'jarvin get {item}')
Example 2: python enumerlate
grocery = ['bread', 'milk', 'butter']
enumerateGrocery = enumerate(grocery)
print(type(enumerateGrocery))
print(list(enumerateGrocery))
enumerateGrocery = enumerate(grocery, 10)
print(list(enumerateGrocery))
<class 'enumerate'>
[(0, 'bread'), (1, 'milk'), (2, 'butter')]
[(10, 'bread'), (11, 'milk'), (12, 'butter')]