Skip to content

Instantly share code, notes, and snippets.

@Bonifacio2
Created June 14, 2018 21:52
Show Gist options
  • Save Bonifacio2/f293b92420eb0032ca63aa00c9e1e4ee to your computer and use it in GitHub Desktop.
Save Bonifacio2/f293b92420eb0032ca63aa00c9e1e4ee to your computer and use it in GitHub Desktop.
# coding: utf-8
with open('mahistory') as word_file:
words = word_file.read().split('\n')
word_dict = {}
for word in words:
count = word_dict.get(word, 0)
new_count = count + 1
word_dict[word] = new_count
for word in sorted(word_dict, key=word_dict.get, reverse=False)[-20:]:
print word, word_dict[word]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment