Stocking out: Problem


I keep getting error alert:
File "python", line 21
total += prices[item]
IndentationError: expected an indented block

That part of the code worked on the previous exercise, why not in this one?

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


You need to indent the code lines inside the if-block.
When a new statement is introduced (here if-statement), the code inside of it must be indented (generally by 4 space bars).


Like allways, I realized this right after sending the question. Thanks anyay!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.