Stock not decrementing


#1

stock not decrementing

Oops, try again. 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}

it says i should not call the compute bill function but the instructions ask me to decrement the count by one.

Thanks Citizens!

def compute_bill(food):
    total = 0
    for key in food:
        if stock[key]>0:
            total += prices[key]
            stock[key] -= 1
    return total


#2

by a function call and the decrement are two completely different things? do you have a computer_bill function call? If so, remove it

If not, can i see your full code?


#3

stock = {
    "banana": 6,
    "apple": 1,
    "orange": 32,
    "pear": 15
}
    
prices = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
}

## Write your code below!
# Write your code below!
def compute_bill(food):
    total = 0
    for key in food:
        if stock[key]>0:
            total += prices[key]
            stock[key] -= 1
    return total

#4

your stock is wrong, there should be zero apples in stock


#5

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