FOR statement

Lad python at hope.cz
Sat Oct 21 03:20:46 EDT 2006


wittempj at hotmail.com wrote:
> Lad wrote:
> > If I have a list
> >
> > Mylist=[1,2,3,4,5]
> > I can print it
> >
> > for i in Mylist:
> >    print i
> >
> > and results is
> > 1
> > 2
> > 3
> > 4
> > 5
> >
> >
> > But how can I  print it in a reverse order so that I get
> > 5
> > 4
> > 3
> > 2
> > 1
> >
> >
> >
> > ?
> >
> >
> > Thanks.
> > L
>
> reverse the list in place with reverse method
>
> l.reverse()
> for i in l:
>     print i
> 
> and the reverse it back if needed

Thank you ALL for help.
L.




More information about the Python-list mailing list