Making a purchase


I don't know where I made a mistake. Would appreciate any kind of help. Thank you in advance.

Error : Oops, try again. compute_bill(['apple']) returned 0 instead of 2

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

print compute_bill(shopping_list)


An index must be a single item, not a list. Use key in place of food.


Hey I tried it. It is showing the same error. Thank you though..


This conditional is not needed.


Yes sir, it helped. Thank you.

Also, there was another error in my code.

for key in prices:

for key in food:


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