# Day at the Supermarket 11/13 and 12/13

#1

This has happened continuously throughout this task, but upon typing both the correct answer, and then using the solution that Codecademy provides, the result is listed as having errors.

In both 11 and 12 when I clicked the ‘Show Solution’ nothing changed in the code written, and googling around has shown that this is the correct solution that people used, however, I keep getting errors like this:

‘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}’

The task at hand directly asks you to substract from the stock.

This is getting incredibly frustrating because I can’t tell if I am making mistakes when the marker is rejecting the exact correct answer.

#2

#3

#4

Lesson 11 tells us to ignore the quantity in stock, and just add the value of any food list.

``````def compute_bill(food):
total = 0
for item in food:
total += prices[item]

print compute_bill(shopping_list)
``````

Lesson 12 tells us to subtract 1 from stock items we compute…

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

print compute_bill(shopping_list)
``````

#5

Hi,
For lesson 12, I have written following code

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

same as you mentioned above

Answer printed is 5.5 which is correct, but still i am getting error as
‘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}’

Can you explain where I am wrong ?

#6

All fine and good, except you did not read the instructions. The answer to this problem is in the error message…

Make sure to not call compute_bill since it changes the stock!

#7

Hi mtf,
Thanks for the help. Now I came to know where I made mistake. The code running fine now.

#8

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