What is enumerate and how it is used with example

what is enumerate and how it is used with example

Enumerate function is used to get the index of the element and the element as well while we are iterating through a loop.

image

you can see above how we are retrieving the element and index of the data.
and by the second method, you get a tuple containing index and the element at that index.

1 Like