Stocking out?


my error came out to:

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

def compute_bill(food):
    total = 0
    for u in food:
        if stock[u] > 0:
            stock[u] = stock[u] - 1
            total += stock[u]
            print 'out of stock'
    return total



total += stock[u]

you add how many products are in stock to total, shouldn't this be the price of the product?


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