📜  python循环列表从最后到第一个 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:17.260000             🧑  作者: Mango

代码示例1
# credit to the Stack Overflow user in the source link
>>> a = ["foo", "bar", "baz"]
>>> for i in reversed(a):
...     print(i)
... 
baz
bar
foo
# in case you want to keep track of the index
>>> for i, e in reversed(list(enumerate(a))):
...     print(i, e)
... 
2 baz
1 bar
0 foo