A day at the Supermarket - Making a purchase.
shopping_list = ["banana", "orange", "apple"] #price and stock omitted # Write your code below! def compute_bill(food): total = 0 for food in shopping_list: total = total + prices[food] return total
Error message: Oops, try again. compute_bill(['apple']) returned 7.5 instead of 2
I don't understand why I can't call the values within shopping_list as variables "food".
I know now after a search in the FAQ that the following is correct:
def compute_bill(food): total = 0 for item in food: total = total + prices[item] return total
Why can't I use "food" as the variable instead of "item"?
Is it because I called "shopping_list" as the reference list?
Appreciate your help, thanks!