day1/debug_exercise.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Mon, 12 Oct 2009 16:29:11 +0530
changeset 101 919c93e5aa71
parent 86 f657495cf8b2
permissions -rw-r--r--
Merged Mainline and Madhu branches.

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