day1/debug_exercise.py
changeset 86 f657495cf8b2
parent 30 3e21614218f4
--- a/day1/debug_exercise.py	Thu Oct 08 19:45:43 2009 +0530
+++ b/day1/debug_exercise.py	Fri Oct 09 12:59:55 2009 +0530
@@ -1,3 +1,13 @@
-def no_bug():
-    for i in range(10):
-        if 
+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