NEVER WORKING! A Day at the Supermarket #11 Making a Purchase


#1



I am stuck on a Day at the Supermarket 11. Making a Purchase.


I get the error message: "Oops, try again. compute_bill(['apple']) returned 0 instead of 2"


I expected it to simply... work.


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:
            total += prices[item]
            stock[item] -= 1

    return total

https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/2/2?curriculum_id=4f89dab3d788890003000096


#2

This is the code for the next exercise, in this exercise you shouldn't check if the item is in stock, that is for the nexercise


#3

OH MY GOSH IT WAS THAT EASY!! Thanks sir!


#4