Friday, August 10, 2012

Python: iterate for loop backwards

use reversed() method:


>>> array=[0,10,20,40]
>>> for i in reversed(array):
...     print i

reference:
http://stackoverflow.com/questions/3940128/how-can-i-reverse-a-list-in-python

No comments: