Latest web development tutorials

Pythonは演習73と、

Pythonの100リー Pythonの100リー

タイトル:反転出力リスト。

プログラム解析:なし。

ソースコード:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    ptr = []
    for i in range(5):
        num = int(raw_input('please input a number:\n'))
        ptr.append(num)
    print ptr
    ptr.reverse()
    print ptr

上の例の出力は、次のとおりです。

please input a number:
6
please input a number:
5
please input a number:
3
please input a number:
4
please input a number:
8
[6, 5, 3, 4, 8]
[8, 4, 3, 5, 6]

Pythonの100リー Pythonの100リー