12: Stocking Out


#1

Working on section 12, stocking out. I thought my code was fine but whenever I run it the error message says:
"calling compute_bill with a list containing 1 apple, 1 pear, and 1 banana resulted in 4 instead of the correct 7".
I'm guessing it's just calculating the price of the banana, as opposed to all three, but I'm not sure where I went wrong! Thank you

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

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


#2

a function ends the moment a return keyword is reached, if a return keyword is reached in a loop, the loop simply breaks


#3

Thank you, that worked!


#4