Looping through a sequence : enumerate « Buildin Function « Python






Looping through a sequence

Looping through a sequence

# the position index and corresponding value can be retrieved at the same time using 
# the enumerate() function.

 
for i, v in enumerate(['tic', 'tac', 'toe']):
     print i, v



           
       








Related examples in the same category