samedi 4 juillet 2020

Is there a way to loop a set of if statements?

Listed below is the code I've written so far. What I'm trying to do is after the user inputs whether they want to add another new item or not I want the code to start over at the newItem input line so that I don't have to just keep the if train going and end up adding a cap to it. Is anybody able to help? I'm still pretty new to python.

shopping_cart_menu = [] 
shopping_cart_prices = []

print("Welcome to the shopping cart program. Please select an option from the menu below.")
print("*******************")
print("01: Add a new Item")
print("02: Display Cart contents")
print("03: Remove Item")
print("04: Compute Total")
print("05: Quit")
print("*******************")

menuAnswer = input(" ")

if menuAnswer == "01":
    newItem = input("What item would you like to add? ")
    shopping_cart_menu.append({newItem})
    followUp = input("Would you like to add another item? Y/N: ")
          if answer = "Y"

Aucun commentaire:

Enregistrer un commentaire