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


#1


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

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

Why it doesn't count correctly?


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

#2

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


#3

Thank you so much! It works now :slight_smile: