for loop counting backward?

Alex Martelli aleaxit at yahoo.com
Sun Oct 12 13:18:18 EDT 2003


Eric Wichterich wrote:

> Hello,
> 
> I am converting a perl-script to python and have problems with this
> simple perl-statement:
> 
> for ( $i = 100; $i > 2; $i-- ) {do something }
> 
> Does anyone know how to write this in python? I did not find any
> documentation about counting backward in a for loop...

for i in range(100, 2, -1):
    dosomething(i)


Alex





More information about the Python-list mailing list