Error caculatind stocking out


#1

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

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 a in food:
if prices[a]>0:
total += prices[a]
stock[a]-=1

return total

and the error is" 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"
can't find where is the problem


#2

solved, had called the wrong dictionary need to call stocks and called pricesxD


#3

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

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

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

Write your code below!

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