mercredi 15 juillet 2020

Python function logic returning wrong value

This is my program. The problem is if I only give the food value, the function return the wrong part. But if I give both value works fine

x = str(input())
y = str(input())

def food(x,y = "Mohakhali"):
    if x == "BBQ Chicken Cheese Burger" and y == "Mohakhali":
        print(250+(250*0.08)+40)
    elif x == "BBQ Chicken Cheese Burger" and y != "Mohakhali":
        print(250+(250*0.08)+60)
    elif x =="Beef Burger" and y =="Mohakhali":
        print(170+(170*0.08)+40)
    elif x =="Beef Burger" and y !="Mohakhali": #for only Beef Burger function prints this.
        print(170+(170*0.08)+60)
    elif x =="Nana Drums" and y =="Mohakhali":
        print(200+(200*0.08)+40)
    elif x =="Nana Drums" and y !="Mohakhali":
        print(200+(200*0.08)+60)
    else:
        print("We dont sell that")
(food(x,y))

Aucun commentaire:

Enregistrer un commentaire