Help in a day at the supermarket lesson 11 making a purchase


#1

been trying this one for a while,

i think the code is correct, but keeps giving me the error:

Oops, try again. compute_bill(['banana', 'apple', 'orange', 'pear']) returned 4 instead of 10.5

and it should return the correct sum, 10.5

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:
        total += prices[item]
        return total


#2

A function ends the moment a return keyword is reached, which now happens in the first run of the for loop. You might want to re-indent it, so the return is outside the for loop