Skip to content

Instantly share code, notes, and snippets.

@svanderbleek
Created January 11, 2019 06:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svanderbleek/ee3671cf38e9b6459c5d08559c0d60cf to your computer and use it in GitHub Desktop.
Save svanderbleek/ee3671cf38e9b6459c5d08559c0d60cf to your computer and use it in GitHub Desktop.
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)
@californiacal
Copy link

Nice. You get to have a job at FB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment