FarmGround=input("Do you want to pat the animal? ") #this is the input
if FarmGround==("Yes") or FarmGround==("yes"): #this is if
print("You patted the animal") #print statement if you patted the animal it will go onto the next if statement
if print=("You patted the animal"):
elif FarmGround==("No") or FarmGround==("no"): #this is elif
print("You didn't patt the animal and it is triggered")
您可以缩进其他语句,包括现有
if
块中的if
语句,就像缩进第一条print
语句一样。你的问题不清楚你到底想做什么,所以我将填充一些伪代码(你可以用你真正想要的任何东西替换):你的密码很清楚。我的理解是你想问另一个问题,如果动物被拍。你知道吗
缩进在python中很重要。要在另一个if语句中嵌套if语句,只需在第一个if语句下面缩进4个空格即可。你知道吗
相关问题 更多 >
编程相关推荐