day1/exercise/kwfreq.py
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 10 Dec 2010 00:04:52 +0530
branchscipyin2010
changeset 450 80028e4eee3d
parent 380 669b72283b55
permissions -rw-r--r--
Fixed day2/session2.tex.

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