12 - stocking out: Fixed


Hey there person, my code is:

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

And it's all tabbed out properly. The code should be right but I 'got' an error of: "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" . It works the same either way without the [item] next to the first stock but it's a bit picky as I finally learnt.


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