FOR statement
Grant Edwards
grante at visi.com
Fri Oct 20 11:39:20 EDT 2006
On 2006-10-20, Lad <python at hope.cz> wrote:
> If I have a list
>
> Mylist=[1,2,3,4,5]
[...]
> But how can I print it in a reverse order so that I get
> 5
> 4
> 3
> 2
> 1
Another option:
>>> Mylist=[1,2,3,4,5]
>>> for i in Mylist[::-1]:
... print i
...
5
4
3
2
1
But, I think the reversed(Mylist) way is better.
--
Grant Edwards grante Yow! Where's the Coke
at machine? Tell me a joke!!
visi.com
More information about the Python-list
mailing list