你好我是python编码的新手,我想知道为什么输入它会产生if语句。
def opnbx():
opn = input("in frount of you is a box do you open it? ")
if opn == "yes" or "Y" or "y" or "Yes":
print("you open the box")
elif opn == "no" or "No" or "N" or "n":
print("you ignore the box and move on")
else:
print("please repeat...")
opnbx()
opnbx()
答案 0 :(得分:0)
试试这个:
def opnbx():
opn = input("in frount of you is a box do you open it? ")
if opn in ("yes", "Y", "y", "Yes"):
print("you open the box")
elif opn in ("no", "No", "N", "n"):
print("you ignore the box and move on")
else:
print("please repeat...")
opnbx()
opnbx()