Python -enumerate()- Funktion
Beispiel
Konvertieren Sie ein Tupel in ein Aufzählungsobjekt:
x = ('apple', 'banana', 'cherry')
y = enumerate(x)
Definition und Verwendung
Die enumerate()
Funktion nimmt eine Sammlung (z. B. ein Tupel) und gibt sie als Aufzählungsobjekt zurück.
Die enumerate()
Funktion fügt einen Zähler als Schlüssel des Aufzählungsobjekts hinzu.
Syntax
enumerate(iterable, start)
Parameterwerte
Parameter | Description |
---|---|
iterable | An iterable object |
start | A Number. Defining the start number of the enumerate object. Default 0 |