day1/exercise/kwfreq.py
author Christopher Burns <chris.d.burns@gmail.com>
Tue, 22 Jun 2010 00:03:19 -0700
branchscipy2010
changeset 422 5f43f3020c51
parent 380 669b72283b55
permissions -rw-r--r--
Merge changes from Prabhu.

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

print freq