Build a Discount Calculator - Build a Discount Calculator

Tell us what’s happening:

I keep getting an error for tests 9 and 10.

I can’t figure out what’s wrong with this code. Please help.

Your code so far

def apply_discount(price, discount):
    if isinstance(price, int) or isinstance(price, float):
        if isinstance(discount, int) or isinstance(discount, float):
            if price > 0:
                if (0 < discount < 100):
                    final_price = price * (1 - discount/100)
                else:
                    return("The discount should be between 0 and 100")
            else:
                return("The price should be greater than 0")
        else:
            return("The discount should be a number")
    else:
        return("The price should be a number")
    return(final_price)

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0

Challenge Information:

Build a Discount Calculator - Build a Discount Calculator

Have you looked at what function returns for these cases? You can add at the end of code (outside of the function definition) ie.:

print(apply_discount(50,0))

I have and it works according to the terminal, but the tests still show that it’s wrong.

So for the above code with print, there’s 50 printed? I’m seeing The discount should be between 0 and 100 instead.

No 50 isn’t being printed. I’m seeing the same message.

The same message is also showing for print(apply_discount(0,100))

Sorry for the confusion.

Double check this condition. It’s not working as you expect.

GOT IT!

Revised my code and all tests passed.

Thanks!!!