summaryrefslogtreecommitdiff
path: root/day1/debug_exercise.py
blob: b8ae31321cc7c7aee144d27492104e659e7b35f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import keyword
f = open('/path/to/file')

freq = {}
for line in f:
    words = line.split()
    for word in words:
        key = word.strip(',.!;?()[]: ')
        if keyword.iskeyword(key):
            value = freq[key]
            freq[key] = value + 1

print freq