Created
January 11, 2019 06:38
-
-
Save svanderbleek/ee3671cf38e9b6459c5d08559c0d60cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sentence = 'there was once a fox who there enjoyed tea there was once a fox who there enjoyed tea tea' | |
words = sentence.split() | |
counts = {} | |
for word in words: | |
counts[word] = counts.get(word, 0) + 1 | |
top3 = sorted(count.items(), key=lambda x: x[1], reverse=True)[:3] | |
print(top3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. You get to have a job at FB