higher abstractions
  • About
  • Now
  • Archives
  • Categories
  • Tags
  1. Tags
  2. python

Use enumerate() in python instead of your boring for loops

This is going to be a short one. For many tasks, we iterate using for loops of this sort:

#Example: Getting odd numbers out of a list
some_list = [x for x in range(5,20)]

#Boring
for i in range(len(some_list)):
    value = some_list[i]
    if value%2 != 0:
    print …
more ...

  • Social

    • Twitter
    • Github
  • Tags

    • code
    • gitbash
    • python
    • thoughts
    • windows
    • workflow

© 2017 neuclid · Powered by pelican-bootstrap3, Pelican, Bootstrap

Back to top