Alex W. answered 02/04/22
Professional Python Tutor & Full-Time Dev!
>> Collect the user's order in a list.
menu = {"cheese", "bread", "wine"}
orders = []
new_order = input("What would you like to order? Press enter to complete your order.")
while new_order:
orders.append(new_order)
new_order = input("What would you like to order? Press enter to complete your order.")
>>> Modify your conditionals to provide a response if the user tries to order something not on the menu.
menu = {"cheese", "bread", "wine"}
orders = []
continue = True
while continue:
new_order = input("What would you like to order? Press enter to complete your order.")
if order in menu:
orders.append(new_order)
elif order:
print(f"{new_order} is not on the menu!")
else:
continue = False # break out of the loop
I didn't test this code. Let me know what you don't understand here. The keys here are to use input to get the user input, then to use a loop to keep getting new inputs. We need a way out of the loop, so I added that, and then we can use *in* to check if an inputted item is on the menu, so I added that.