<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/2/3?curriculum_id=4f89dab3d788890003000096
<In what way does your code behave incorrectly? Include ALL error messages.>
my code behaves correctly but it gives me this error code
Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 30 instead of the correct 7
<What do you expect to happen instead?>
i expect no error messages
#shopping_list = [“banana”, “orange”, “apple”];
shopping_list = {“apple” : 1, “pear”:1, “orange” : 0, “banana”: 1};
#shopping_list = {“banana”: 1, “orange” : 1, “pear” : 1};
#shopping_list = {“banana”: 9, “orange” : 3, “apple” : 0, “pear” : 0};
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):
pTotal = 0
total = 0
for kFood in food:
if stock[kFood] > 0:
if shopping_list[kFood] >= stock[kFood]:
pTotal = stock[kFood] * prices[kFood];
#stock[kFood] = 0;
else:
pTotal = shopping_list[kFood] * prices[kFood];
#stock[kFood] = stock[kFood] -shopping_list[kFood];
total = total + pTotal;
return total
print compute_bill(shopping_list);
<do not remove the three backticks above>