#11 Making a Purchase


I tried to look at other solutions, and got more confused.
Could someone take a look at my problem?
thank you

Oops, try again. compute_bill(['apple']) resulted in a TypeError: unhashable type: 'list'

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


this line:

total = total + prices[food]

food contains a list of all the items, prices can only deal with one item at a time, which is in item, so use prices[item]


I appreciate the explanation why, that went with the help.
thank you that worked


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