I'm learning python and im still a beginner and heres my problem:
toppinglist = []
instock = ['Cheese', 'Tomato', 'Chicken', 'Mushroom']
Outofstock = ['Beef', 'Pork', 'Onions']
wanttoppings_q = input('Do you want toppings on your pizza? Yes/No')
wanttoppings_q = wanttoppings_q.title()
while wanttoppings_q == 'Yes':
requestedtopping = input('Enter One Topping:')
toppinglist.append(requestedtopping)
anythingelse = input('Anything Else? Yes/No' )
anythingelse = anythingelse.title()
toppinglist = []
if anythingelse == 'No':
break
print(toppinglist)
with this block of code, basically goal is asking what pizza toppings you want then adding that to a list, i tried using my brain and came up with this. Everything is fine, while loop fine but then i print the topping list and nothings inside. Maybe im using append wrong? pls help
you are resetting the toppinglist = [] before you are printing it so remove that everything will work fine
toppinglist = []
instock = ['Cheese', 'Tomato', 'Chicken', 'Mushroom']
Outofstock = ['Beef', 'Pork', 'Onions']
wanttoppings_q = input('Do you want toppings on your pizza? Yes/No ')
wanttoppings_q = wanttoppings_q.title()
while wanttoppings_q == 'Yes':
requestedtopping = input('Enter One Topping: ')
toppinglist.append(requestedtopping)
anythingelse = input('Anything Else? Yes/No ')
anythingelse = anythingelse.title()
if anythingelse == 'No':
break
print(toppinglist)