Enumerate (Python)
Allows you to print both the index and the value.
my_list = ['apple', 'banana', 'cherry']
for index, value in enumerate(my_list):
print(index, value)
"""
Output:
0 apple
1 banana
2 cherry
""
Allows you to print both the index and the value.
my_list = ['apple', 'banana', 'cherry']
for index, value in enumerate(my_list):
print(index, value)
"""
Output:
0 apple
1 banana
2 cherry
""