iterating in reverse

Jonathan P. jbperez808 at yahoo.com
Fri Jan 17 09:23:04 CET 2003


> Get the Python 2.3 alpha, and it's really easy :)
> 
> >>> l = [1,2,3,4,5]
> >>> for i in l[::-1]:
> ...     print i
> ... 
> 5
> 4
> 3
> 2
> 1
> 
> -Andrew.

Ach...!  That's definitely the easiest on the 
eyes (wonder about the performance implications
though).  Still a bit of an eyesore... but we 
Python programmers are really too spoiled. ;-D




More information about the Python-list mailing list