Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #! /usr/bin/python
  2.  
  3. file=open("sometext.txt","r+")
  4. wordcount={}
  5. wordslist = file.read().split()
  6. wordslist.sort()
  7. for word in wordslist:
  8. if word not in wordcount:
  9. wordcount[word] = 1
  10. else:
  11. wordcount[word] += 1
  12. words = []
  13. counts = []
  14. for word,count in wordcount.items():
  15. words.append(word)
  16. counts.append(count)
  17.  
  18. print("word - {0}, have maximum counts of: {1}".format(words[counts.index(max(counts))],max(counts)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement