Stocking Out - Unhashable Type


The code outputs: "calling compute_bill with a list containing 1 apple, 1 pear and 1 banana caused the following error: unhashable type: 'list'"

It should output correctly.

def compute_bill(food):
    total = 0
    for item in food:
        if stock[item] > 0: 
            total += prices[food]
            stock[item] -= 1
    return total


You seem to use item for the two lines above and below. But why use food in the middle?


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