Stocking out - Correct results, but still not working


Any guidance will be very much appreciated.

The code I am submitting gives me the right calculations in compute_bill and updates the stock, but I am still getting the same error message:
Oops, try again. stock doesn't look quite right! Make sure to not call compute__bill since it changes the stock! It should contain: {'orange': 32, 'pear': 15, 'banana': 6, 'apple': 0}

Why should the stock list look the same after we subtract one from the item's stock count?

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

print compute_bill(shopping_list)
print stock


Remove or comment out the last two lines. They will be added in the next lesson.


Thank you, @mtf !!!
I am new to Python and I tend to over-think a bit.


The exercises are generally basic and simple. For best results read and follow instructions closely. That way your work will meet the expectations. Happy coding!


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