# 12.Stocking Out - error

#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 f in food:
if stock[f]>0:
total+=prices[f]
stock[f]=stock[f]-1
print compute_bill(shopping_list)

it always says:
**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 MY PROGRAM IS WRONG?

12.Stocking Out
#2

from the error message:
Make sure to not call compute_bill since it changes the stock

look at this line of your code:

``print compute_bill(shopping_list)``

you call computer_bill (i never understood why this wasn't allowed, but it isn't)

#3

I also would prefer that they allow the user to call the `compute_bill` function in this exercise. After all, we should test the functions that we write.

Codecademy does allow us to call the `compute_bill` function in the final exercise, which is Exercise 13: Let's Check Out!, although they do not actually ask us to do it. So, we can each feel free to take the initiative to test the function there without being rebuffed by an unfriendly "Oops, try again." message.

11. Making a purchase- Help please!
#4

HI its doesn't allow because the Lesson doesn't want you to change the stock

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

the function compute_bill() remove items from the stock when you call it with the shopping_list() it look like

``````stock = {
"banana": 5,
"apple": 0,
"orange": 31,
"pear": 15
}``````

its remove one item so ....if you want to call the just add item to the item in the stock

``````stock = {
"banana": 7,
"apple": 0,
"orange": 33,
"pear": 15
}``````

only to the one in the shopping_list. SO in this case when it will remove the items it will be the list the Lesson want you to pass with.
Hope that make you understand it