THE WORLD'S LARGEST WEB DEVELOPER SITE

Python enumerate() Function

❮ Built-in Functions


Example

Convert a tuple into an enumerate object:

x = ('apple', 'banana', 'cherry')
y = enumerate(x)
Run example »

Definition and Usage

The enumerate() function takes a collection (e.g. a tuple) and returns it as an enumerate object.

The enumerate() function adds a counter as the key of the enumerate object.


Syntax

enumerate(iterable, start)

Parameter Values

Parameter Description
iterable An iterable object
start A Number. Defining the start number of the enumerate object. Default 0

❮ Built-in Functions