def test(word, ex): for letter in word: if letter in ex: return False return True print('Dictionary searcher') f = open(input('Dictionary file: ')) words = f.read().split('\n') f.close() print(len(words), 'words loaded') print('Loading modules...', end='') import fnmatch print(' done\n') cheat = False while True: pattern = input('Search: ') if pattern == '!': cheat = True continue matched = fnmatch.filter(words, pattern) if cheat: exclude = input('Exclude: ') matched = list(filter(lambda a: test(a, exclude), matched)) print('Found', len(matched), 'matching words\n') print('\n'.join(matched)) print()