IndentationError: expected an indented block


#1

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

what's indented block in total+= prices[item] ? I cannot figure out.


#2

Code with proper indentations:

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

It should be obvious that total += prices[item] should have one level deeper indentation than if statement.


#3

Oh I see.
thanks
fixed~


#4

You're very welcome! :panda_face: