Making a purchase not working


#1

I am fairly certain my code should be working properly however every time I run i get an error message like:

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

This is my code:

def compute_bill(food):
total = 0
for key in food:
total = total + prices[key]
return total

any ideas as to why its not working?


#2

Hii t's maybe an indent problem try it with that indent

def compute_bill(food):
    total = 0
    for key in food:
        total = total + prices[key]
    return total

#3

I feel like an idiot for not remembering the indent, thanks a million.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.