Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python iterate backwards through list

>>> a = ["foo", "bar", "baz"]
>>> for i in reversed(a):
...     print(i)
... 

or

>>> for i, e in reversed(list(enumerate(a))):
...     print(i, e)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #iterate #list
ADD COMMENT
Topic
Name
6+8 =