enumerate (iterable, start = 0) Parameters: Iterable: any object that supports iteration Start: the index value from which the counter is to be started, by default it is 0
code > Exit: Using enumeration object in loops
# Python program to illustrate
# enumerate function
# create enum objects
" Return type: "
type code >
# change starting index to 2 from 0
Return type: [(0, `eat`), (1,` sleep`), (2, `repeat` )] [(2, `g`), (3,` e`), (4, `e`), (5,` k`)]
Using enumeration object in loops
(0, `eat`) (1, `sleep`) (2,` repeat`) 100 eat 101 sleep 102 repeat
This article courtesy of Harshit Agrawal . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you`d like to share more information on the topic discussed above.