I am having trouble with where to locate a list append so the values keep getting accumulated in the list as it goes through the loop. The code does the following:
- Shows Pizza Menu and Extras to the customer
- Customer picks a pizza
- Code asks if the customer wants any extras
- When the customer is done with adding extras, the code will ask if there is another order
- When the customer is done with ordering pizza, I want code to display the list of pizzas in this order and their prices.
I added an empty list selected=[] and tried to append it every time it prompts the user to make a selection. Where do I make a mistake?
Newyork=['Mozarella','Pepperoni','Basil','Green Pepper']
Veggie=['Mozarella', 'Mushroom', 'Green Pepper', 'Onion']
Margarita=['Spicy Tomato Sauce', 'Mozarella']
BBQ=['Mozarella', 'BBQ Sauce','Grilled Chicken', 'Onion' ]
Extra=['Olive','Salami','Sausage','Corn']
extselect=[]
selected=[]
Price_newyork= 10
Price_veggie= 12
Price_margarita= 8
Price_BBQ= 15
print("Welcome to Pizza MIS")
print("---------------------------Menu--------------------------")
print("Newyork:", Newyork)
print("Veggie:", Veggie)
print("Margarita:", Margarita)
print("BBQ:", BBQ)
print("Extra's:", Extra)
def main():
selection=input("Which pizza do you prefer?: ")
selected=selected.append(selection)
extra= input('Would you like to add extra ingredients? Yes or No: ')
while extra== 'Yes' or extra=='yes':
extselect=input("Enter the extra ingredient you want to add your pizza: ")
try:
extselect_index=Extra.index(extselect)
if selection=='Newyork' or selection=='newyork':
Newyork.insert(0,extselect)
print ("Here is your new selection:", Newyork)
extra=input('Do you want to add another ingredient? (Yes or No): ')
if selection=='Veggie' or selection=='veggie':
Veggie.insert(0,extselect)
print ("Here is your new selection:", Veggie)
extra=input('Do you want to add another ingredient? (Yes or No): ')
if selection=='Margarita' or selection=='margarita':
Margarita.insert(0,extselect)
print ("Here is your new selection:", Margarita)
extra=input('Do you want to add another ingredient? (Yes or No): ')
if selection=='BBQ' or selection=='bbq':
BBQ.insert(0,extselect)
print ("Here is your new selection: ", BBQ)
extra=input('Do you want to add another ingredient? (Yes or No): ')
except ValueError:
print("That item was not found in the Extra list")
extra=input('Do you want to add an extra ingredient? (Yes or No): ')
try:
if selection== 'Newyork' or selection=='newyork':
print("Here is your selection: ")
print(Newyork)
price(selection)
if selection=='Veggie' or selection=='veggie':
print("Here is your selection: ")
print(Veggie)
if selection== 'Margarita' or selection=='margarita':
print("Here is your selection: ")
print(Margarita)
if selection== 'BBQ' or selection=='bbq':
print("Here is your selection: ")
print(BBQ)
again=input('Do you want to order another pizza? (Yes or No) ')
if again=='Yes':
main()
else:
print('Bye')
except ValueError:
print("That item was not found in the list ")
def price(selection):
if selection== 'Newyork' or selection=='newyork':
print('It will cost USD',Price_newyork)
elif selection== 'Veggie' or selection=='veggie':
print('It will cost USD',Price_veggie)
elif selection== 'Margarita' or selection=='margarita':
print(Price_margarita)
elif selection== 'BBQ' or selection=='bbq':
print('It will cost USD',Price_BBQ)
else:
print('Enter again')
main()