Enumerate is a built-in function which return a enumerate object which consists of tuple containing a count (from start which defaults to 0) and the values obtained from iterating over sequence. In simple terms it add counter to the sequence.
>>> fruits = ['Banana', 'Apple', 'Lime']
>>> for item in enumerate(fruits):
print(item)
(0,'BANANA')
(1,'APPLE')
(2,'LIME')
It is used to get the values printed along with indexes.
No comments :
Post a Comment