I also tried this for discount:
if (discount is not int) or (discount is not float):
return 'The discount should be a number'
I also tried this for discount:
if (discount is not int) or (discount is not float):
return 'The discount should be a number'
it also didn’t work sadly
why are you using a different method here for price and for discount?
this is the most recent code:
def apply_discount(price, discount):
if (price is not int) or (price is not float):
return('The price should be a number')
if (discount is not int) or (discount is not float):
return 'The discount should be a number'
so you decided on this method? is it working? have you tested it?
have you tested the other method?
This is wrong it does not work:
This is correct:
Can you see the difference? Test it!
ok I’ll test it and see if it works
but also what I have currently for the price detection works so I’m still gonna see if it’ll work
Do not test the full code.
Erase everything (or use a different editor https://www.online-python.com/) and test one statement at a time.
I tested this and it didn’t work:
def apply_discount(price, discount):
a
if(isinstance(discount, int)):
return('The discount must be a number')
if(isinstance(discount, float)):
return('The discount must be a number')
the a is to avoid an error
now that I realize it the a is useless
so here is the same code without the a:
def apply_discount(price, discount):
if(isinstance(discount, int)):
return('The discount must be a number')
if(isinstance(discount, float)):
return('The discount must be a number')
and it still failed the test
So, if the discount is an integer you want to return “The discount must be a number” ?
It seems like an integer IS a number
I’ll answer any questions you have and help you but in the end you have to write this code and figure it out.
I see the mistake now thank you for pointing it out
edited and it still doesn’t want to pass that test
def apply_discount(price, discount):
if(isinstance(discount, int) is False):
return('The discount must be a number')
if(isinstance(discount, float)is False):
return('The discount must be a number')
consider what happens if it a float to isinstance(discount, int)
consider what happens if it is an int to isinstance(discount, float)