2017年7月17日月曜日

開発環境

Head First Python (Paul Barry (著)、O'Reilly Media)のChapter 3.(Structured Data: Working with Structured Data)の SHARPEN YOUR PENCIL(No. 2621) を取り組んでみる。

SHARPEN YOUR PENCIL(No. 2621)

コード(Emacs)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

vowels = {'a', 'e', 'i', 'o', 'u'}
word = input('Provide a word to search for vowels: ')

print(f'word: {word}')

found = vowels.intersection(set(word))

for vowel in sorted(found):
    print(vowel)

入出力結果(Terminal, IPython)

$ ./sample2.py < sample2.py
Provide a word to search for vowels: word: #!/usr/bin/env python3
e
i
o
u
$ ./sample2.py < sample2.py | ./sample2.py
Provide a word to search for vowels: word: Provide a word to search for vowels: word: #!/usr/bin/env python3
a
e
i
o
u
$

0 コメント:

コメントを投稿