python3练习100题——032

链接:http://www.runoob.com/python/python-exercise-example32.html

题目:按相反的顺序输出列表的值。

我的代码:

for i in li[::-1]:
    print(i)

或者

li.reverse()
for i in li:
    print(i)

reverse只是对li进行操作,没有返回值。如果print(li.reverse()) 只会输出None。

猜你喜欢

转载自www.cnblogs.com/drifter/p/9197236.html