I am stuck on 11. Making a Purchase in A Day at the Supermarket


#1



11. Making a Purchase


Oops, try again. compute_bill(['apple']) resulted in a TypeError: list indices must be integers, not str


shopping_list = ["banana", "orange", "apple"]

stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
}
    
prices = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
}

# Write your code below!
def compute_bill(food):
    total = 0
    for key in food:
        total = total + food[key]
    return total.


#2

You want to increase the total by the price of an item. The prices are stored in the prices dictionary not in the food list.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.