2016年6月11日土曜日

開発環境

Think Python (Allen B. Downey (著)、 O'Reilly Media)のChapter 9.(Case Study Word Play)のExercises 9-1(No. 1961)を取り組んでみる。

Exercises 9-1(No. 1961)

コード(Emacs)

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

count = 0
count1 = 0
words = {}
with open('words.txt') as f:
    for words in f:
        for word in words.split():
            word = word.strip()
            count += 1
            if len(word) > 20:
                count1 += 1
                print(word)
print('{0}/{1}'.format(count1, count))

入出力結果(Terminal, IPython)

$ ./sample1.py
counterdemonstrations
hyperaggressivenesses
microminiaturizations
3/113809
$

0 コメント:

コメントを投稿

Comments on Google+: