How do I make a working if statement that repeats on if false in Python?

Question:

name = input("What is your name?n")

menu = "Black Coffee", "Espresso", "Latte", "Cappucino","Frappuccino"

while True:
   order = input(name + ", what would you like from our menu today? Here is what we are serving.n")
   if order == "Black Coffee":
       print("Thank you.")
   elif order == "Espresso":
        print("Thank you.")
   elif order == "Latte":
        print("Thank you.")
   elif order == "Cappucino":
        print("Thank you.")
   elif order == "Frappucino":
        print("Thank you.")
   else:
       print("play again.. etc...")

quantity = input("How many " + order + "s would you like?n")

total = price * int(quantity)

total_time = int(quantity) * time

print("Thank you. Your total is: $" + str(total))

print("Sounds good " + name + ", we will have your " + quantity + " "+ order + " ready for you in " + str(total_time) + " min.")

I am a guy who is a beginner in Python. I have a problem with my code that when I enter for example "Latte" It will say "Thank you." and it jumps back and says "name + , what would you like from our menu today? Here is what we are serving.". I do not want that to happen, instead I want it to say the line under it (How many " + order + "s would you like?). Also, when I add the variable "menu" to my "order" variable (in the string) it says "can only concatenate str (not "tuple") to str"
I would really appreciate your help.

Asked By: Mr. Slicer

||

Answers:

Use the break keyword to break out of the while loop:

while True:
   order = input(name + ", what would you like from our menu today? Here is what we are serving.n")
   if order in menu:
       print("Thank you.")
       break
   else:
       print("play again.. etc...")
Answered By: Mathias R. Jessen
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.