Press "Enter" to skip to content

Python Notes 12 : Enumerate built in functions

Enumerate

Enumerate allows us to keep a count as we iterate through an object. It returns a tuple in the form (count,element)

Example

lst = [‘a’,‘b’,‘c’]

for (number,item) in enumerate(lst):

   print number

   print item


Output –
0
a
1
b
2
c

 

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *