Example Program: Most Frequent Words import string, sys text = open(sys.argv[1],'r').read() text = text.lower() for ch in string.punctuation: text = text.replace(ch, ' ') counts = {} for w in text.split(): counts[w] = counts.get(w,0) + 1 items = [(c,w) for (w,c) in counts.items()] items.sort() items.reverse() for c,w in items[:10]: print w, c