Answers for "python for list backwards"

7

how to flip a list backwards in python

myList = [0,1,2,3,4,5]
myList.reverse()
print(myList)
#OR
print(myList[::-1])
Posted by: Guest on February-22-2020
2

inverted for python

for i in reversed(range(5)):
    print(i)
Posted by: Guest on September-13-2020
2

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)
Posted by: Guest on December-03-2019

Python Answers by Framework

Browse Popular Code Answers by Language