# The code doesn't seem to work no matter what I do

#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
“calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 2 instead of the correct 7” I don’t know what this means, or where it got some of these numbers like 2 or 7, and it left out orange (in the list) in this error message, just generally confusing. And sometimes “your code looks a bit off, look at the console for help”

<What do you expect to happen instead?>
I expect for the code to work, as it’s instructing me. See if something is in stock, if it is, then deduct it’s stock by one, and add the price to the total, if not in stock, don’t add to total or subtract from stock.

```python 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 i in stock:
if stock[i] > 0:
stock[i] == stock[i] - 1
for i in food:
total = total + prices[i]
elif stock[i] > 0:

``````<do not remove the three backticks above>

Indentations don't save correctly when posted^``````

#2

#3

`stock[i] == stock[i] - 1`

that is a boolean expression. Use a single `=` to assign.

#4

same error, didn’t work

#5

What else does not look right? The return statements, perhaps?

#6

Oh nevermind, I failed so much at it that it gave me the answer. I called the wrong keys or something. Thanks anyway

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

Now compare to a working solution:

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