enumerate in python 3.9.1

Spread the love

In python we deal with many iterators, ex list, we need to keep count of count of objects along with
their indices, for this we use enumerate().

enumerate in python
enumerate in python

python code for enumerate in python 3.9.1

sach = ['python','java','c','c#']
en = enumerate(sach)
print(list(en))
Output:
[(0,'python'), (1,'java'), (2,'c'), (3,'c#')]

We can see it returns tuples of index value with the item at that particular index.
This method can be used with any of the objects on which we can iterate.
Also this method is so wildly used in loops like,
s = [‘python’,’java’,’c’,’c#’]
for count,element in enumerate(s):
here count has the index value and element has the actual element.

Summary :

In this section we are see enumerate in python 3.9.1 so about this section you have any query then free to ask me

Name of Intern who share this Task:

swapnil raj 

sachin Pagar

Mr. Sachin Pagar is an experienced Embedded Software Engineer and the visionary founder of pythonslearning.com. With a deep passion for education and technology, he combines technical expertise with a flair for clear, impactful writing.

Leave a Reply