#!/usr/bin/python import spelling notfound = {} #setdict(dict.txt) file = open('input.txt') for line in file: for word in line.split(): validchars = re.compile('[^A-Za-z\']') word = validchars.sub('', word); if not lookup(word): notfound[word] = notfound.get(word,0) + 1 for key in notfound.keys(): print key + " (" + str(notfound.get(key)) + ")"