Python编程之反向输出列表

版权声明:此篇博文为博主心血o(╥﹏╥)o,如要转载请注明来源,勿忘心安! https://blog.csdn.net/dyq1995/article/details/88813731

问题描述:按相反的顺序输出一个列表的值。

程序分析:控制前后秩序。

源代码:


#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
a = ['one', 'two', 'three']
for i in a[::-1]:
    print i

输出结果如下:

three
two
one

猜你喜欢

转载自blog.csdn.net/dyq1995/article/details/88813731