Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. fname = raw_input("Enter file name: ")
  2. if len(fname) < 1 : fname = "mbox-short.txt"
  3. count = dict()
  4. fh = open(fname)
  5. for line in fh :
  6. if 'From: ' in line :
  7. line = line.split()
  8. word = line[1]
  9. counts[word] = counts.get(word,0)+1
  10. bigcount = None
  11. bigword = None
  12. for word,count in counts.items():
  13. if bigcount is None or count > bigcount:
  14. bigword = word
  15. bigcount = count
  16. print bigword,bigcount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement