LehreWiki

   1 d,l,s={},[],[]
   2 l=file('test.txt').read().split() 
   3 for word in l:
   4         d[word]=l.count(word) 
   5 for word, count in d.items():
   6     s.append([count, word])
   7 s.sort()
   8 for count, word in s:
   9         print word,     count

LehreWiki: Python/Exercise1/Solution (last edited 2008-10-25 23:01:09 by anonymous)