day1/exercise/kwfreq.py
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 10 Dec 2010 00:16:11 +0530
branchscipyin2010
changeset 452 f9417abb23a6
parent 380 669b72283b55
permissions -rw-r--r--
Moved exercises and other minor changes in day2/session3.

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