開発環境
- 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)、Reviewing Our Experiments の SHARPEN YOUR PENCIL(No. 1802) を取り組んでみる。
SHARPEN YOUR PENCIL(No. 1802)
コード(Emacs)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- phrase = "Don't panic!" plist = list(phrase) print(phrase) print(plist) new_phrase = ''.join(plist[1:3]) new_phrase += plist[5] + plist[4] + plist[7] + plist[6] print(plist) print(new_phrase)
入出力結果(Terminal, IPython)
$ ./sample2.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 コメント:
コメントを投稿