我想做的是,如果我问了一个只能用是和回答的问题 不,我想确定答案是肯定还是否定。否则,它将停止
print("Looks like it's your first time playing this game.")
time.sleep(1.500)
print("Would you like to install the data?")
answer = input(">").lower
if len(answer) > 1:
if answer == "no":
print("I see. You want to play portably. We will be using a password system.")
time.sleep(1.500)
print("Your progress will be encrypted into a long string. Make sure to remember it!")
else:
print("Didn't understand you.")
elif len(answer) > 2:
if word == "yes":
print("I see. Your progress will be saved. You can back it up when you need to.")
time.sleep(1.500)
else:
print("Didn't understand you.")
比如:
这是最简单的方法(假设情况无关紧要)
旁注:
正在将对
lower
方法的引用分配给answer
,而不是调用它。您需要添加paren,answer = input(">").lower()
。另外,如果这是python2,则需要使用raw_input
,而不是input
(在python3中,input
是正确的)首先:
应该是
第二,
len(answer) > 1
对"no"
和"yes"
都是正确的(就这点而言,大于一个字符的任何字符)。elif
块永远不会被计算。在不显著修改当前代码逻辑的情况下,您应该改为:相关问题 更多 >
编程相关推荐