How to make a reverse for loop in python?

Alex Snast asnast at gmail.com
Sun Sep 21 01:27:41 CEST 2008


On Sep 20, 8:13 pm, bearophileH... at lycos.com wrote:
> Duncan Booth:
>
> > > e.g. the python equivalent to the c++ loop
> > > for (i = 10; i >= 0; --i)
>
> > The exact equivalent would be:
> >         for i in range(10, -1, -1): print i
>
> I'd use xrange there. Anyway, I have always felt that Python syntax
> not easy to understand at first sight, expecially when you try to
> convert a bit more complex inverted for loops from/to C to/from
> Python. It's one of the few cases where (for example) Pascal (loop)
> syntax wins a bit over Python syntax :-)
>
> Bye,
> bearophile

Another quick question please, is the List data structure just a
dynamic array? If so how can you use static size array, linked list,
AVL trees etcetera.



More information about the Python-list mailing list