As the others:
for i, val in enumerate(data): print i, val
but also
for i, val in enumerate(data, 1): print i, val
In other words, you can specify an initial value for the index / counter generated by enumeration () , which may come in handy if you do not want your index to start with a default value of zero.
I printed lines in a file the other day and indicated the initial value as 1 for enumerate() , which made more sense than 0 when displaying information about a specific line for the user.
Levon Jul 13 '12 at 18:00 2012-07-13 18:00
source share