Getting error in please


Hello All. I am getting an error while compiling the code of the below given exercise.

The exercise url

The error message i am getting is "Oops, try again.
** calling compute_bill with a list containing 2 apples, 2 pears, 3 **
oranges and 8 bananas resulted in 42.5 instead of the correct 34.5"

Please help me because i am not getting the fault of this code.

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:
        if stock[key] >0:
            total= total+(prices[key])
    return total

Stocking out

step 3 of the instructions:

If the item is in stock and after you add the price to the total, subtract one from the item's stock count.

you need to decrease the stock after an item is bought, otherwise it is possible to buy 9 banana's, while you don't have that many in stock


Thank you so much Stetim for helping me


no problem, you still had to do most of the work, did you manage to resolve the issue? If so, well done :slight_smile: i just gave a little notch in the right direction, you figured it out :slight_smile:


Yes Setim i did the job after getting your hint.