[Tutor] Speed of accessing list components

Alan Gauld alan.gauld at blueyonder.co.uk
Sun Jun 27 08:01:55 EDT 2004


> >>> i = 0
> >>> for x in string.ascii_letters:
>         i -= 1
>         print string.ascii_letters[i]
> 

This is quite close to the canonical way of doing 
this using a while loop:

L = [.......]
i = len(L)-1
while i >= 0
   print L[i]
   i -= 1

So much choice...

Alan G.



More information about the Tutor mailing list