I need help with stocking out


#1



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


#3

Hi, @eric0911718,

Wouldn't you want the third of the following three statements to be part of the if block? ...

        if stock[item] > 0:
            total += prices[item]
        stock[item] -= 1

#4

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