- enumerate
- tuple
Enumerate returns tuples
examples/lists/enumerate_tuple.py
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'] enu = enumerate(planets) print(type(enu).__name__) print(enu) print('-----') element = next(enu) print(type(element)) print(element) print('-----') for tpl in enumerate(planets): print(tpl[0], tpl[1])
enumerate <enumerate object at 0x7f7ede7e37c0> ----- <class 'tuple'> (0, 'Mercury') ----- 0 Mercury 1 Venus 2 Earth 3 Mars 4 Jupiter 5 Saturn