2 ms·
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.
by greenspider 12y ago
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.
- maxerickson 12y agoIt first mentions enumerate as a footnote after looping with a range: https://docs.python.org/2/tutorial/controlflow.html#for-statements 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.)