12. Stocking Out error message


#1


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

"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


#2

Your 'loop for' must be outside 'if'


#3

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


#4

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