Skip to main content

enumerate[IterableType: Iterable](ref iterable: IterableType, *, start: Int = 0) -> _Enumerate[IterableType.IteratorType[iterable_is_mut, iterable_is_origin]]

The enumerate function returns an iterator that yields tuples of the index and the element of the original iterator.

Examples

var l = ["hey", "hi", "hello"]
for i, elem in enumerate(l):
    print(i, elem)

Args:

  • iterable (IterableType): An iterable object (e.g., list, string, etc.).
  • start (Int): The starting index for enumeration (default is 0).

Returns:

_Enumerate

Was this page helpful?