day1/debug_exercise.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Fri, 09 Oct 2009 13:20:08 +0530
changeset 87 cd29428cd8f5
parent 86 f657495cf8b2
permissions -rw-r--r--
Added emphbar to boxes in Session 2.

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