所以我正在做一个项目,我从文件中查找单词,然后检查它是否在字典中。我不知道我是否遵循正确的语法,因为它会打印出在字典中找不到“不起作用”的 else 语句。和中间的空格有关系吗?
用多个单词测试术语 - 不起作用:-3
if 'does not work' in dictionary:
expected_value3 = str(-3)
actual_value3 = dictionary['does not work']
if actual_value3 == expected_value3:
print "---------------------------------"
print "words with spaces passes| word: does not work"
else:
print "---------------------------------"
print "words with spaces FALSE| word: does not work"
else:
print "---------------------------------"
print "does not work not in dictionary"