import speling file = open('input.txt') misspelled = list() last = str() for line in file: words = line.split() for word in words: if type(speling.splCheck(word)) == type(None): misspelled.append(word) for word in misspelled.sort(): if word.lower() != last.lower(): print word + ' (' + str(misspelled.count(word)) + ')' last = word