開発環境
- 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)、Exercise(p.13)を解いてみる。
Exercise(p.13)
コード(BBEdit)
sample21.py
#!/usr/bin/env python3 #-*- coding: utf-8 -*- movies = ["The Holy Grail", 1975, 'Terry Jones & Terry Gilliam', 91, ['Graham Chapman', ['Michael Palin', 'John Cleese', 'Terry Gillian', 'Eric Idle', 'Terry Jones']]] for each_item in movies: if isinstance(each_item, list): for inner_each_item in each_item: print(inner_each_item) else: print(each_item)
入出力結果(Terminal)
$ ./sample21.py The Holy Grail 1975 Terry Jones & Terry Gilliam 91 Graham Chapman ['Michael Palin', 'John Cleese', 'Terry Gillian', 'Eric Idle', 'Terry Jones'] $
0 コメント:
コメントを投稿