Python 練習實例32

Python 100例 Python 100例

題目:按相反的順序輸出列表的值。

程式分析:無。

程式源代碼:

實例

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

以上實例輸出結果為:

three
two
one

Python 100例 Python 100例