Stocking out


Please help me find out what’s wrong?

Here is the error:
“calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 4 instead of the correct 7”

# Write your code below!
def compute_bill(food):
  total = 0
  for x in food: 
    if stock[x] > 0:
    	total = total + prices[x]
     	stock[x] = stock[x] - 1
 return total


Please tell, what is your problem?


Please see it above. Cheers


are you sure the indent of your code is right? return total doesn’t match any other indent level


“Return total” lies exactly with loop for


not in the code you copied to the forum, can you post your code again? Its the only mistake i can find


Not sure why it is correct now after I hit many times run :expressionless:. A bit weird but I move onto the final one now. Thanks though, cheers