What is the improvement in enumerate() function of Python?

In Python, enumerate() function is an improvement over regular iteration.

The enumerate() function returns an iterator that gives (0, item[0]).

E.g.

>>> thelist=[‘a’,’b’]

>>> for i,j in enumerate(thelist):

print i,j

0 a

1 b


Posted

in

Tags:

Comments

Leave a Reply