Don't understand the error i'm getting


#1

11.
oops try again compute_bill['banana', 'apple', 'orange', 'pear'] returned 4 instead of 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

Hi return should be indent like that

....
    for item in food:
        total += prices[item]
    return total

#3

It worked thanks a lot


#4

Do you see why indenting it one way causes the function to return 4, and another results in the correct result? And even more importantly, how you can use the error message to figure out what the problem was?