#1

Hello All. I am getting an error while compiling the code of the below given exercise.

The exercise url

The error message i am getting is "Oops, try again.
** calling compute_bill with a list containing 2 apples, 2 pears, 3 **
oranges and 8 bananas resulted in 42.5 instead of the correct 34.5"

``````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 key in food:
if stock[key] >0:
total= total+(prices[key])

Stocking out
#2

step 3 of the instructions:

If the item is in stock and after you add the price to the total, subtract one from the item's stock count.

you need to decrease the stock after an item is bought, otherwise it is possible to buy 9 banana's, while you don't have that many in stock

#3

Thank you so much Stetim for helping me

#4

no problem, you still had to do most of the work, did you manage to resolve the issue? If so, well done i just gave a little notch in the right direction, you figured it out

#5

Yes Setim i did the job after getting your hint.

#6