# 12 Stocking Out


#1



I have looked at other posts and tried to compare, and I still do not see my mistake. Can someone please help?



Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 9 instead of the correct 7


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


#2

It seems you are missing the if statement,try this one:
def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total = prices[item] + total
stock[item] -= 1
return total

and put the total and stock[item] setter inside the if statement and the if statement inside the for statement with 4 spaces respectively


#3

thank you it worked: smile_cat:


#4

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