You can get access to the loop index in Python by using the enumerate()
function to loop over your iterable:
for index, value in enumerate(['spam', 'eggs', 'ham']): print index, value
Reference: PEP 279 – The enumerate() built-in function
You can get access to the loop index in Python by using the enumerate()
function to loop over your iterable:
for index, value in enumerate(['spam', 'eggs', 'ham']): print index, value
Reference: PEP 279 – The enumerate() built-in function