Please Help! Stocking out bug


Replace this line with your code. 
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 key in food:
        total += prices[key]
    return total

The error message says "calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 9 instead of the correct 7." I don't get it. 4 + 3 + 2 = 9. Please help!


you haven't done anything of the exercise? You need to check the item/product customer wants to buy is actually in stock, apple is not in stock, so it can't be sold and you shouldn't charge the customer for it


Oh. My bad. I didn't read that part


Go read it, see if you can figure out how to code that

If you can't figure it out, i can help your further (include your code, error message and question)


I figured it out right after I read your comment. Thanks!