How can I do this in python?
array = [0,10,20,40] for (i = array.length() - 1 ;i >= 0; i--)
I need to have the elements of an array but from the end to the beginning.
Sommaire |
How can I do this in python?
array = [0,10,20,40] for (i = array.length() - 1 ;i >= 0; i--)
I need to have the elements of an array but from the end to the beginning.
http://docs.python.org/release/2.4.4/whatsnew/node7.html http://docs.python.org/release/2.4.4/whatsnew/node7.html
>>> array=[0,10,20,40] >>> for i in reversed(array): ... print i
Note that reversed(...) does not return a list. You can get a reversed list using list(reversed(array)).
License : cc by-sa 3.0
http://stackoverflow.com/questions/3940128/how-can-i-reverse-a-list-in-python