開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Head First Python (Paul Barry(著)、 O'Reilly Media; )のChapter 1(meet python - Everyone loves lists)、Sharpen your pencil(p.29)を解いてみる。
Sharpen your pencil(p.29)
コード(BBEdit)
sample29.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
def printLoL(the_list):
for each_item in the_list:
if isinstance(each_item, list):
printLoL(each_item)
else:
print(each_item)
movies = ["The Holy Grail", 1975, 'Terry Jones & Terry Gilliam', 91,
['Graham Chapman',
['Michael Palin', 'John Cleese', 'Terry Gillian', 'Eric Idle',
'Terry Jones']]]
if __name__ == '__main__':
printLoL(movies)
入出力結果(Terminal)
$ ./sample29.py The Holy Grail 1975 Terry Jones & Terry Gilliam 91 Graham Chapman Michael Palin John Cleese Terry Gillian Eric Idle Terry Jones $
0 コメント:
コメントを投稿