def word_source():
word_list = []
sorted_words = {}
sourse = open(PATH_TO_DICT, 'r')
for line in sourse:
line = line.strip("\n")
word_list.append(line)
for word in word_list:
sorted_word = sorted_string(word)
if sorted_word in sorted_words:
sorted_words[sorted_word].append(word)
else:
sorted_words[sorted_word]=[word]
return sorted_words
sorted_word_dictionary = word_source()
while True:
wrd = input("Enter String: ").strip()
if wrd == 'exit()':
print('Script stopped')
exit()
if not ''.join(sorted(wrd)) in sorted_word_dictionary:
print('No matches found')
else:
print('Matches found')