Hello! My name is Thomas and I'm a nerd. I like tech and gadgets and speculative fiction, and playing around with programming. It's not my day job, but I'm working on making it a side gig :)
enumerate is a great tool and it's what you should use when you actually need the index for something, but most of the time people don't really need the index.
And there's a better way to use it:
forindex,valueinenumerate(foo):# voilà, the values are already unpacked# into two handy variables!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I see a lot of this when people want to use the index to do something instead of using
for i in enumerate(foo)
which returns(index, value)
enumerate
is a great tool and it's what you should use when you actually need the index for something, but most of the time people don't really need the index.And there's a better way to use it: