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

I keep getting the error:"calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in None instead of the correct 7" not sure what I am doing wrong.


#2

When a function has no return statement, the console responds with None. Change the print to return.