How to make a reverse for loop in python?

Simon Brunning simon at brunningonline.net
Sat Sep 20 12:36:54 EDT 2008


2008/9/20 Alex Snast <asnast at gmail.com>:
> I'm new to python and i can't figure out how to write a reverse for
> loop in python
>
> e.g. the python equivalent to the c++ loop
>
> for (i = 10; i >= 0; --i)

for i in range(10, 0, -1):
    print i

-- 
Cheers,
Simon B.



More information about the Python-list mailing list