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]).

>>> thelist=[‘a’,’b’]
>>> for i,j in enumerate(thelist):
… print i,j

0 a
1 b

Leave a Reply

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