- enumerate
Enumerate lists
examples/lists/enumerate.py
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'] for idx, planet in enumerate(planets): print(idx, planet)
0 Mercury 1 Venus 2 Earth 3 Mars 4 Jupiter 5 Saturn
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'] for idx, planet in enumerate(planets): print(idx, planet)
0 Mercury 1 Venus 2 Earth 3 Mars 4 Jupiter 5 Saturn