<AptiCode/>

Question 416: What does theenumeratefunction do when used in aforloop?

tcs
wipro
infosys
general
aptitude
loops
python-programming

Theenumerate()function adds an index to each element in an iterable, returning pairs of index and element.my_list = ['apple', 'banana', 'orange', 'grape'] for index, value in enumerate(my_list): print(f"Index: {index}, Value: {value}")Output:Index: 0, Value: apple Index: 1, Value: banana Index: 2, Value: orange Index: 3, Value: grape