If statement question


Write your code below!

def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total += prices[item]
stock[item] -= 1
return total
print stock
{'orange': 31, 'pear': 15, 'banana': 5, 'apple': -1}

Question: Why does it take the value from the apple stock if the statement was: if stock[item] > 0:


Please re-edit your Post

  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.