I am working on a programme to get the total of items ordered in a store, for instance. I created a dictionary called menu for the availabile items, but if the item ordered in the list of orders is not among the keysame of my dictionary "menu", that item should be replaced with Coke.
My intention is to convert the items to their prices, which are the corresponding values in the dictionary and do the necessary total afterwards.
But it seems, like in the example, Popcorn is not giving way😃😃😃. Pls help.
a = ["Pizza", "Cheeseburger", "Water", "Popcorn"]
menu = {"Nachos":6,"Pizza":6,"Cheeseburger":10,"Water":4,"Coke":5}
for i in a:
if not i in menu:
i = "Coke"
print(a)
Aucun commentaire:
Enregistrer un commentaire