開発環境
- macOS Sierra - Apple (OS)
- Emacs (Text Editor)
- Python 3.6 (プログラミング言語)
Head First Python (Paul Barry (著)、O'Reilly Media)のChapter 2.(List Data: Working With Ordered Data) の SHARPEN YOUR PENCIL(No. 1765) を取り組んでみる。
SHARPEN YOUR PENCIL(No. 1765)
コード(Emacs)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- phrase = "Don't panic!" plist = list(phrase) print(phrase) print(plist) new_phrase = phrase[1:3] + phrase[5] + phrase[4] + phrase[7] + phrase[6] new_phrase = ''.join(new_phrase) print(plist) print(new_phrase)
入出力結果(Terminal, IPython)
$ ./panic2.py Don't panic! ['D', 'o', 'n', "'", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!'] ['D', 'o', 'n', "'", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!'] on tap $
0 コメント:
コメントを投稿