day1/exercise/word_frequencies.py
changeset 380 669b72283b55
parent 64 333092b68926
--- a/day1/exercise/word_frequencies.py	Mon Mar 08 20:45:33 2010 +0530
+++ b/day1/exercise/word_frequencies.py	Thu Mar 11 18:01:23 2010 +0530
@@ -1,11 +1,13 @@
-f = open('/home/madhu/pyprogs/pytriads.py')
+f = open('/home/vattam/Desktop/circulate/word-freq/holmes.txt')
 
 freq = {}
 for line in f:
     words = line.split()
     for word in words:
         key = word.strip(',.!;?\'" ')
-        value = freq.get(key, 1)
-        freq[key] = value + 1
+        if key in freq:
+            freq[key] += 1
+        else:
+            freq[key] = 1
 
 print freq