12. Stocking Out


Hi. I’m a little stuck again. I think i have a clue what im supposed to do. what i was trying to do is make it so that if the stock is greater than 0, it will include the price in the total. im also trying to include a part in if where if stock is grater than 0 and it includes the price in the total, the stock for that item will go down by 1, but i have no clue how im supposed to do it.
def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total += prices[item]
stock[item] = (stock[item] - 1)
return total

its the second last line that i just dont get how to make it so python understands. i keep getting this error message
File “python”, line 23
stock[item] = (stock[item] - 1)
IndentationError: unindent does not match any outer indentation level
help would be appreciated


for multiple lines of code, use code block (3 backticks above and below code)

the problem seems to be here:

    	total += prices[item]
     stock[item] = (stock[item] - 1)

these indent levels do not match, the indent levels should match


A post was split to a new topic: 12. stocking out


i was messing around with all the indents within the if part and it turned out that the stock[item] part had to be indented within the line before, even though trhat was indented from the if part