Pythonic Code Using Enumerate

Use enumerate to iterate to each list's element

1>>> # Pythonic Example
2>>> animals = ['cat', 'dog', 'moose']
3>>> for i, animal in enumerate(animals):
4...     print(i, animal)
5...
60 cat
71 dog
82 moose

If the index is not important, use "_" in place of "i":

1>>> # Pythonic Example
2>>> animals = ['cat', 'dog', 'moose']
3>>> for _, animal in enumerate(animals):
4...     print(animal)
5... 
6cat
7dog
8moose

Or more simply, without using "enumerate" function:

1>>> # Pythonic Example
2>>> animals = ['cat', 'dog', 'moose']
3>>> for animal in animals:
4...     print(animal)
5...
6cat
7dog
8moose

If you're familiar with shell scripting, the last one is familiar as it is similar to one way to iterate in bash:

 1strings="
 2the
 3quick
 4brown
 5fox
 6"
 7for x in $strings; do
 8    echo $x
 9done
10
11the
12quick
13brown
14fox