Stocking Out - stuck on this one


I'm stuck on this one and not sure what is wrong. Why would it want to return 2 instead of 0. There are no apples so it should be o, right?

Error message:

Oops, try again. compute_bill(['apple']) returned 0 instead of 2

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 produce in food:
        if stock[produce] > 0:
            total += prices[produce]
            stock[produce] -= 1
    return total



Ignore whether or not the item you're billing for is in stock.

so now it doesn't ignore that.

we just need total price of any food list. we don't need to check whether it is in stock or not.


There is no issue with the code i copied it and pasted it into my editor and it allowed me to pass to the next stage


It still returns the same error. What Ih ad to do for some buggy reason is to change the quantity of apple in the beginning lists


can you please post the update version of your code?


Any solution for this? Please let's help out gurus in the house!


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