I am working on a program to get the total of items ordered in a store, for instance. I created a dictionary called menu for the available items, but if the item ordered in the list of orders is not among the key. Same 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.
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)