How do I make this work? I understand that “total_price” isn’t iterable but I’m still unsure of how to fix it.
order_menu = {("C", "Chips (Scoops)") : 2.80, ("F", "Fish (Battered)") : 2.90, ("Fc", "Fish (Crumbed)") : 4.90, ("Fib", "Filet (Battered)") : 6.90, ("Fic", "Filet (Crumbed)") : 6.90,
("Hd", "Hot Dog") : 2.60, ("S", "Sausage") : 2.60, ("Mp" , "Meat Patty (Homemade)") : 3.90, ("Cr", "Crabstick") : 2.50, ("Sr", "Spring Roll (Homemade)") : 2.80,
("Cr", "Curry Roll (Homemade)"): 2.80, ("Pof", "Potato Fritter (Homemade)") : 1.20, ("Paf", "Paua Fritter (Homemade)") : 5.90, ("Cn", "Chicken Nugget") : 1,
("Mh", "Mini Hot Dog (On a stick)") : 1.20, ("Pf", "Pineapple Fritter") : 2.50}
order_dictionary = {"Chips (Scoops)" : 3, "Curry Roll (Homemade)" : 5, "Sausage" : 2}
ordered_food = {}
for food, quantity in order_dictionary.items():
for (key, food_name), price in order_menu.items():
if food == food_name:
total_price = quantity * price
print("• {} x{} (${:.2f})".format(food, quantity, total_price))
ordered_food[(food, quantity)] = (price, total_price)
buy = input("Type '-1' to cancel, press any other key to continue.)")
if buy == "-1":
active_ordering = False
else:
for (food, quantity), (price, total_price) in ordered_food.items():
print("• {} Qty: {} ${} each Total ${:.2f}".format(food, quantity, price, total_price))
total = round(sum(total_price), 2)
print(total)