A day at supermarket..plzz help


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

error msg:Oops, try again. compute_bill(['apple']) returned 0 instead of 2


which exercise are you at?

if this is making a purchase, don't check if item is present in stock


still it is showing the same error


post update version of your code so that we can see what you've change.

also include the link that goes to the lesson


I just did it based on your code. If you remove the check you made for the stock, everything works out well on my end.


Oh, like rcodeman mentioned, I was on exercice 11... But I just did exercice "12. Stocking Out" and you might just want to avoid calling the function in the end.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.