【发布时间】:2019-01-06 02:38:03
【问题描述】:
因此,作为我在 python 上的第一个项目,我正在尝试制作一个像程序一样的二分法键,它会在提出问题后猜测你在想什么动物,我对此真的很陌生,所以试着简单地解释一下 :) .也很抱歉,如果这个问题在其他地方被问过,我真的不知道该怎么问。
think=input ("Think of an animal. Type ready when you want to begin")
think=think.upper()
#FUR
if think=="READY" :
fur=input ("Does it have fur?")
else :
print ("I'll be waiting")
if fur=="YES" :
legs=input ("Does it walk on four legs?") :
elif fur=="NO" :
reptile=input ("Is it a reptile?")
#REPTILE
if reptile=="YES" :
shell=input ("Does it have a shell?")
if reptile=="NO" :
fly=input ("Can it fly?")
#LEGS
if legs=="YES" :
pet=input ("Do people own it as a pet?")
if legs=="NO" :
marsupial=input("Is it a marsupial?")
如果您在腿上回答“是”,我无法让它跳到“人们是否拥有它作为宠物”。此外,“我会等待”(其他)不起作用。哦,这是 python 3.x 顺便说一句。
为格式化而编辑
编辑 2:在我的比较中去掉括号 :)
【问题讨论】:
-
请在您的代码中显示缩进。
-
只是一个指针:比较中不需要括号。
-
think=think有点不必要
标签: python if-statement conditional-statements