vendredi 19 janvier 2018

else and elif statements result in if statement

hello I am new to python coding and am wondering why whatever is inputted it results in the if statement.

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()

Aucun commentaire:

Enregistrer un commentaire