12. Stocking Out error message



"Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana caused the following error: local variable 'item' referenced before assignment"

So i'm stuck at this point and i keep getting this error message. What's wrong? ):

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


Your 'loop for' must be outside 'if'


oh i see i reversed the lines
thanks a lot (:


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