print("Welcome to your phones Troubleshooter")
issue = input(str("Does your phone have an issue?"))
if [issue == "yes", "Yes", "YES"]:
我已经为三个选项设置了参数 yes,但它似乎不起作用,它只是继续转到我的 else 语句。 我该怎么办?
你可以
这样做:
print("Welcome to your phones Troubleshooter")
issue = input(str("Does your phone have an issue?"))
if issue.lower() == "yes":
print("There is an issue")
或者代码的 if 语句稍有改动:
print("Welcome to your phones Troubleshooter")
issue = input(str("Does your phone have an issue?"))
if issue == "yes" or issue == "Yes" or issue == "YES":
print("There is an issue")
您应该阅读 if 语句语法。你做错了。
print("Welcome to your phones Troubleshooter")
issue = input(str("Does your phone have an issue?"))
accepted_string = {"yes", "Yes", "YES"}
if issue in accepted_string:
print("Found it")
else:
print("Not found")