The enumerate() is a predefined function in Python and used to add counter to an iteration and returns it in a form of enumerate object.
Syntax of Python enumerate()
enumerate(iterable, start=0)
Here, the iterable is a sequence, an iterator and start parameter is the number from where the counting starts. This is an optional parameter, by default 0 is taken as starting number.
This is the following solution to keep count of this given list starting from 100.
items = ["Suger", "Tea", "Rice", "Wheat", "Salt", "Pulse"]
# set the start index to 100
for count,ele in enumerate(items,100):
print count,ele
Solution
The enumerate() is a predefined function in Python and used to add counter to an iteration and returns it in a form of enumerate object.
Syntax of Python enumerate()
enumerate(iterable, start=0)Here, the iterable is a sequence, an iterator and start parameter is the number from where the counting starts. This is an optional parameter, by default 0 is taken as starting number.
This is the following solution to keep count of this given list starting from 100.
Output of the above code
100 Suger
101 Tea
102 Rice
103 Wheat
104 Salt
105 Pulse
need an explanation for this answer? contact us directly to get an explanation for this answer