Python enumerate() Function
Example
Convert the tuple to an enumerable object:
x = ('apple', 'banana', 'cherry') y = enumerate(x)
Definition and Usage
The enumerate() function accepts a collection (such as a tuple) and returns it as an enumeration object.
The enumerate() function adds a counter as the key of the enumeration object.
Syntax
enumerate(iterable, start)
Parameter Value
Parameter | Description |
---|---|
iterable | Iterable Object |
start | Number. Defines the starting number of the enumeration object. The default value is 0. |