Making a purchase - Code doesn't work and i dont know why


Error message: compute_bill(['banana', 'apple', 'orange', 'pear']) returned 4 instead of 10.5

Why it doesn't count correctly?

def compute_bill(food):
    for item in food:
        total += prices[item]
        return total
print compute_bill(["banana", "orange", "apple"])


Back off the indentation on this line so it lines up with the for, and is outside of the loop.


Thank you so much! It works now :slight_smile: