Build an Apply Discount Function - Build an Apply Discount Function

Tell us what’s happening:

can anyone provide correct code i tried hints but doesnt works can any one complete code

Your code so far

def apply_discount (price, discount):
    
    calc_discount = price*(1-discount/100)

    ver_discount = (price, discount)

    if isinstance(ver_discount, int or float): 
        print("The price should be a number")
         
        if ver_discount < 0 :
           print("The price should be greater than 0") 

        if ver_discount > 100: 
            print("The price should be greater than 0") 

        
   

    return calc_discount 

Your browser information:

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

Challenge Information:

Build an Apply Discount Function - Build an Apply Discount Function

Welcome to the forum @prajapatikamal830 !

Does it make sense to do any calculations before you validate whether price and discount are numbers?

You cannot validate two variables at the same time with isinstance(), but you can check multiple types for a variable by passing in a tuple as the second argument.

Here’s an example of the syntax from this reference

print(isinstance(b, (int, list,str)))

Unfortunately, I’ve seen similar code on the forum, so remember that when you use someone’s code from the forum, you are also getting their errors.

Happy coding!