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 = [] for w,c in counts.items(): items.append((c,w)) items.sort() items.reverse() for i in range(10): c,w = items[i] print w, c