import speling misspelled_words_dict = {} def parse_file(text_file): """Reads in a text file and returns a list of 'sentences'. A 'sentence' is defined to be just a line of text. """ file = open(text_file) alist = [] for line in file: alist.append(line) return alist sentence_list = parse_file('foo.txt') for i in sentence_list: misspelled_list = sentcheck(i) for j in misspelled_list: if j in misspelled_words_dict: misspelled_words_dict[j] = misspelled_words_dict[j] + 1 else: misspelled_words_dict[j] = 1 keys = misspelled_words_dict.keys() for k in misspell_keys: print k + ' (' + repr(misspelled_words_dict.get(k)) + ')'