Build an Apply Discount Function - Build an Apply Discount Function

Tell us what’s happening:

After typing the line 'apply_discount(100, 20), 80 was shown. However, when I clicked on ‘Check Your Code’, it kept telling me 'apply_discount(100, 20) should return 80. Which I believe is exactly what I had done, but it just won’t let me check and move on.

Your code so far

def apply_discount(price, discount):

    if not isinstance (price, (int or float)):
        return ('The price should be a number')
    elif not isinstance(discount, (int or float)):
        return ('The discount should be a number')
    elif price<=0:
        return('The price should be greater than 0')
    elif discount<0 or discount>100:
        return('The discount should be between 0 and 100')
        
    print(price-(price*discount/100))

apply_discount(100,20)



Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.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

return is an important keyword, when you use print that is not what the function returns

Thanks. I also noticed that when I do the(74.5,20.0) it wouldn’t work at first, but right after I changed (int or float) to (int, float), everything worked out all of a sudden. But to be honest I’m not sure about the difference tho, does using ‘or’ and ‘,’ makes a big difference?

yes, one is not the correct syntax to use isinstance with multiple data types, the other is