Stocking Out


#1



https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/2/3?curriculum_id=4f89dab3d788890003000096#

Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 9 instead of the correct 7

honestly I have no idea what I am doing wrong here. The answer is supposed to return 7?
This is my 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 item in food:
        if food > 0:
            total += prices[item]
            stock[item] -= 1  
    return total


#2

Hi, @terajumper40772 ,

You are performing the wrong test here ...

if food > 0:

Instead, test whether stock[item] is greater than 0.


#3

Thanks so much! I think my problem is I am not fluent yet in reading python, so I did not check that little thing.