Patternite Logo

Keeping track of the current iteration index in a `for` loop, Python

1

We can use the built-in `enumerate`generator to keep track of the current `for` loop iteration index

Loading...

The built-in enumerate generator makes it easy to keep track of the current iteration index in a for loop. enumerate is not just limited to use in for loops however, though this is likely the most common usecase.

Profile picture for duncster

Patternite © 2021

Patternite Logo