day1/exercise/word_frequencies.py
changeset 64 333092b68926
child 380 669b72283b55
equal deleted inserted replaced
63:f5eac04a00fe 64:333092b68926
       
     1 f = open('/home/madhu/pyprogs/pytriads.py')
       
     2 
       
     3 freq = {}
       
     4 for line in f:
       
     5     words = line.split()
       
     6     for word in words:
       
     7         key = word.strip(',.!;?\'" ')
       
     8         value = freq.get(key, 1)
       
     9         freq[key] = value + 1
       
    10 
       
    11 print freq