如果用户对以上三个问题都回答“否”,我想打印一条消息,说要接听电话。如何编写程序来知道所有3个答案都是“否”并打印消息
asleep = input("Are you sleep?")
if asleep == "yes":
print("You will not answer the phone.")
if asleep == "no":
print("You will answer the phone.")
momCall = input("Is it mom calling?")
if momCall == "yes":
print("You will answer the phone.")
if momCall == "no":
print("You will not answer the phone.")
morning = input("Is it morning?")
if morning = "yes":
print("You will not answer the phone.")
if morning = "no":
print("You will answer the phone")
您的输入应该是比较运算符。我相信你把“是”和“否”混为一谈了。一个建议是仔细阅读如何使用if/elif/else语句
您可以将所有答案添加到列表中,并验证所有元素是否相等
相关问题 更多 >
编程相关推荐