Build an Apply Discount Function - Build an Apply Discount Function

Tell us what’s happening:

the code outputs ‘The price should be a number’ when the price is a string. But the tests still arent being checked even though the code does exactly what the test is asking for. Is there something i am missing? Help appreciated, thanks.

Your code so far

def apply_discount(price,discount):
    if not isinstance(price, (int, float)):
        print("The price should be a number")

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36

Challenge Information:

Build an Apply Discount Function - Build an Apply Discount Function

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-discount-calculator/695774002591bbc5f8cf3e53.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @AlistairDied,

If price is not a number (int or float), the function should return the string The price should be a number

What does it say the function should do if price is not a number? Is that what you’re doing?

Happy coding

it says that if the price is not a number then the function should return “The price should be a number”

Yes, and do you return that message? Or are you printing it instead?

Ohh! That was the problem. You needed to return “The price should be a number” , not print it! Thankyou for your help.