1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| from difflib import get_close_matches
my_input = input() input_list = my_input.split(' ')
lst = [] with open("wordlist.txt") as new_file: for line in new_file: lst.append(line.strip())
new_sentence = "" suggestions = {} for i in range(0, len(input_list)): if input_list[i].lower() in lst: new_sentence += f"{input_list[i]} " else: new_sentence += f"*{input_list[i]}* "
suggestions[input_list[i]] = get_close_matches(input_list[i], lst)
print(new_sentence) print("Suggestions:") for word, suggs in suggestions.items(): print(f"{word}: {', '.join(suggs)}")
|