Stocking out?


#1


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]
        else:
            print 'out of stock'
    return total


#3

here:

total += stock[u]

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


#4

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