Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python
- file=open("sometext.txt","r+")
- wordcount={}
- wordslist = file.read().split()
- wordslist.sort()
- for word in wordslist:
- if word not in wordcount:
- wordcount[word] = 1
- else:
- wordcount[word] += 1
- words = []
- counts = []
- for word,count in wordcount.items():
- words.append(word)
- counts.append(count)
- 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