Overview:
-
Given an iterable, the built-in function enumerate() returns an iterator which returns an index and the element from the iterable as a tuple upon each call to the __next__().
-
The index is zero based. The index can be modified to start with a non-zero value by passing in the required starting index value to the start parameter of the enumerate() function.
Example:
# Example Python program that creates an enumerate # Start with index 1 try: # Will print indices 3 and 4 except StopIteration: |
Output:
(1, 'Slide') |