How can I make the other condition work in where I put what order I like because even though I put or "milktea"
after the == "Milktea"
it still does not work. I want to make it that even when the user input a small letter it will still not continue but it doesn't.
PS: How can i make the pgln = input under the def cstmrinfo only put a string in it because even though i put number it counts as a string and continue to the next function pgln= str(input()) does not work
print("GOOD DAY WElCOME TO OUR MILKTEA SHOP.")
mnu = ["Milktea", "Foods", "Drinks", "Dessert"]
flvrs = ["1.Matcha-100", "Taro-100", "Honey Dew-95", "Winter
Melon-90", "Okinawa-100", "Chocolate-90",
"Cheese Cake-110"]
pgkn = {'Chicken'}
shot = ["tubig"]
mtms = ["ice cream"]
laht = []
print("Hi what would you like to be called, "
"So we can inform you if your order is ready")
def cstmrinfo(name):
print("Okay " name, "So what would you like to get " )
print(mnu)
pngln= (input())
def kuha_order():
while True:
order = input()
if order in mnu:
print(order)
if order == "Milktea":
print(flvrs)
laht.append(order)
break
elif order == "Foods":
print(pgkn)
laht.append(order)
break
elif order == "Drinks":
print(shot)
laht.append(order)
break
elif order == "Dessert":
print(mtms)
laht.append(order)
break
else:
print("Sorry you input a thing that is not available on our menu, "
"Please Try again:")
continue
def pnglhtn() :
print("I Would like to get a: ")
qwe = input()
print(qwe)
dmi = int(input("How Many Servings Would you Like: "))
print(dmi)
laht.append(qwe)
laht.append(dmi)
print("So " pngln, "you Like a " str(laht[:2]))
print (dmi, "Servings")
cstmrinfo(pngln)
kuha_order()
pnglhtn()
CodePudding user response:
You can use either lower() or upper(). Please check the following answer:
if order.lower()=="milktea":
print(flvrs)
laht.append(order)
break
OR
if order.upper()=="MILKTEA":
print(flvrs)
laht.append(order)
break
CodePudding user response:
When using the logical "or" operator in an if...else statement in python you have to repeat the variable as well as the value (i know that sounds confusing so look at the example)
this means that this won't work:
if order == "Milktea" or "milktea":
the correct formation should be:
if (order == "Milktea") or (order == "milktea"):
alternatively if you want to simply check one variable against a range of values check out the match...case statements in python 3.10 : https://learnpython.com/blog/python-match-case-statement/
######################################################
Remove the if order in mmu line and indent the corresponding else (code listed below)
def kuha_order():
while True:
order = input()
print(order)
if order == "Milktea":
print(flvrs)
laht.append(order)
break
elif order == "Foods":
print(pgkn)
laht.append(order)
break
elif order == "Drinks":
print(shot)
laht.append(order)
break
elif order == "Dessert":
print(mtms)
laht.append(order)
break
else:
print("Sorry you input a thing that is not available on our menu")
continue
you can combine this with my answer above to get what you need :)