A day at the supermarket: 12. Stockin Out - code not working


#1

Hello, I'm stucked in lesson 12 of "A day at the supermarket", my code doens't work and I don't know why.
Here my code:

shopping_list = ["banana", "orange", "apple", "pear"]

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}

prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}

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

return total

print compute_bill(shopping_list)

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}

I really don't know what is wrong, because to me everything seens fine.
The console print the total of 8,5, is this correct?

Thank you for the help


#2

Remove or comment this line...


#3

Thank you! So easy... I'm a little embarrassed lol


#4

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