Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

read this right after using a range in a loop in order to get the index. Can't believe I went this long without knowing about enumerate.


It first mentions enumerate as a footnote after looping with a range:

https://docs.python.org/2/tutorial/controlflow.html#for-stat...

But the tutorial in the Python docs has pretty high information density and good coverage of things like this.

(I think there is some risk that this comment will be interpreted as If you don't know enumerate you need to look at the tutorial. That isn't what I intend, I just want to point out that the tutorial is a reasonably dense resource that hits on a lot of stuff like enumerate.)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: