Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Enumerate lists

  • enumerate
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn']
for idx, planet in enumerate(planets):
    print(idx, planet)

Output:

0 Mercury
1 Venus
2 Earth
3 Mars
4 Jupiter
5 Saturn