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。

 

posted @ 2018-06-19 09:52  Drifter_y  阅读(401)  评论(0编辑  收藏  举报