The Day I Discovered enumerate()

It was a regular evening debug session. My code was working, but something about it just felt off. I was looping over a list—like always. for i in range(len(my_list)): value = my_list[i] # Do something with value and i Nothing wrong, right? Except... I was starting to hate reading my own code. It felt noisy. Clunky. Too much range(len(...)). Too much manual indexing.

May 6, 2025 - 14:59
 0
The Day I Discovered enumerate()

It was a regular evening debug session. My code was working, but something about it just felt off. I was looping over a list—like always.

for i in range(len(my_list)):
    value = my_list[i]
    # Do something with value and i

Nothing wrong, right?

Except... I was starting to hate reading my own code.
It felt noisy. Clunky. Too much range(len(...)). Too much manual indexing.