day1/exercise/word_frequencies.py
changeset 64 333092b68926
child 380 669b72283b55
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/word_frequencies.py	Thu Oct 08 18:59:47 2009 +0530
@@ -0,0 +1,11 @@
+f = open('/home/madhu/pyprogs/pytriads.py')
+
+freq = {}
+for line in f:
+    words = line.split()
+    for word in words:
+        key = word.strip(',.!;?\'" ')
+        value = freq.get(key, 1)
+        freq[key] = value + 1
+
+print freq