Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Just a frequency analysis
import string
t = open("trump", "r")
words = {}
for line in t:
for w in line.split():
word = string.strip(w, ":,.\"").lower()
if word in words:
words[word] += 1
words[word] = 1
for word, _ in sorted(words.items(), key = lambda x: x[1]):
print word, words[word]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment