Stocking out: Is this correct?


#1

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

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

Is the ode right?


#2

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:


#3

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


#4

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


#5

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.


#6

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