Stocking out


#1

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

#2

Please tell, what is your problem?


#3

Please see it above. Cheers


#4

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


#5

“Return total” lies exactly with loop for


#6

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


#7

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


#8