Skip to content

Improve code readability with enumerate() #4

Description

@aleide

The enumerate(iterator, start index) function gives you an iterator that returns both an index, starting at 'start index', and the regular output from 'iterator'. If 'iterator' has multiple return values they will be packaged as a tuple when using enumerate.

Example:
for index, item in zip(range(len(iter_object)), iter_object):
could be re-written as
for index, item in enumerate(iter_object):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions