Answer to Question #304190 in Python for Daniel

Question #304190

How do I construct a loop for my input statements? Input question is, "What type of coffee would you like today?" If user selects a coffee, they pass, but if they fail, they must retry.


order = input("\n" + first_name.capitalize() + "," " " + "What type of Coffee would you like today?\n\n" +
              "\n".join(["Expresso", "Latte", "Cappuccino", "Mocha", "Frappuccino"]) + "\n\n")

order = order.replace("and a", "")
order = order.replace("and", "")
order = order.replace(",", "")
order = order.lower().split()

union = " and a " if len(order) > 1 else ""

plural = "" if len(order) > 1 else ""

order = input("\nYou have selected a" + " " + ", ".join(order[:-1]).title() + union + plural + order[-1].title()
              + "!" + " " + "\n\nIs this correct?\n\n")













1
Expert's answer
2022-03-01T07:12:35-0500
i = 0
list1 = ['expresso', 'latte', 'cappucino', 'Mocha' ]
while i:
    input1 = input('What type of coffee do you have')
    if input1 in list1:
        break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS