Stocking out: Is this correct?


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):
for key in food:
if stock[key] > 0:
total= total + prices[key]
return total

Is the ode right?


are you getting any error message?

you need to format your code properly here so that we can see.

have a look at this forum :slight_smile:


sorry can you tell me why isn't my text font family Garamond?


It is just showing None! should not it show some numbers?


There is no print statement in your code then how should it be?

you have to call the function with print statement.

But in this lesson you shouldn't call the function as it changes the stock.


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