Build an Apply Discount Function - Build an Apply Discount Function

Tell us what’s happening:

“When apply_discount is called with a price (first argument) that is not a number (int or float) it should return The price should be a number.”

I don’t understand why this doesn’t work, type or isinstance isn’t working. pls help

Your code so far

def apply_discount(price,discount):
    if not (type(price, int) or type(price, float)):
        return('The price should be a number')
   
    

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.3.1 Safari/605.1.15

Challenge Information:

Build an Apply Discount Function - Build an Apply Discount Function

I figured it out, I didn’t need to split using an “or”

if not type(price, (int, float)):

solved my issue

Welcome to the forum @reviii !

That’s the syntax for isinstance(), not type().

Happy coding!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.