Python enumerate() function
Python enumerate() function The enumerate() function in Python takes a collection (e.g. a tuple) and returns it as an enumerate object. Syntax:
enumerate(iterable, start=0)Parameter Iterable: This parameter represents an iterable object start: This parameter represents a number defining the start number of the enumerate object, and by default, its value is 0 Return This function returns an enumerate object. Example 1
# Python Program explaining # enumerate() function val1 = ('cat', 'dog', 'rat') val2 = enumerate(val1) print(list(val2))Output
[(0, 'cat'), (1, 'dog'), (2, 'rat')]