#11 Making a Purchase


#1



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


#2

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]


#3

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


#4

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