Day at super market error


#1



Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 6 instead of the correct 7


where did it go wrong?


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


#2

Check your indentation. This is very important.


#3

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

is this what you mean? i changed stock[item] to prices[item] and now it gives this

Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 4 instead of the correct 7


#4

All of the indentation is correct except for the last line. But that last change also helped.


#5

Aside

You could use the same pattern in the second line that you used in the first.


#6

but that still gives me the same error


#7

Quite possibly because it wasn't about the error. We've already pointed that out. The indentation on the last line.


#10