> That's two new things I've learnt. I didn't realise that for loops
> could be used like that (with more than one... key?).

Technically its still one key but enumerate returns a tuple 
of index and value and we use tuple unpacking to assign 
the values to the loop variables. That is we could write it like:

for tup in enumerate(sequence):
     index = tup[0]
     value = tup[1]
     # process stufff here
OR:
for tup in enumerate(sequence):
     index,value  = tup
     # process stufff here

Which becomes
for index, value in enumerate(sequence):
     # process stufff here

HTH,

Alan G.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to