Stocking Out - Unhashable Type


#1



https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/2/3?curriculum_id=4f89dab3d788890003000096


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


#2

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


#3

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