所以基本上我在一个文本文件中有一个很大的单词列表,当用户输入一个来检查拼写时,我希望能够搜索到匹配的单词,这就是我目前所拥有的。
f = open('words.txt', 'r')
wordCheck = input("please enter the word you would like to check the spelling of: ")
for line in f:
if 'wordCheck' == line:
print ('That is the correct spelling for '+wordCheck)
else:
print ( wordCheck+ " is not in our dictionary")
break
当我输入一个单词时,我会立刻得到else语句,我甚至不认为它会读过文本文件。 我应该改用while循环吗?
while wordCheck != line in f
我是python新手,最终我希望用户能够输入一个单词,如果拼写不正确,程序应该打印出一个匹配单词的列表(75%的字母或更多匹配)。
任何帮助都将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐