I can not seem to see my error. It says that discount should return the string when not a number but its the same code for price and that resolves correctly
Your code so far
def apply_discount(price,discount):
if isinstance(price,int) ==False or isinstance(price,float) ==False:
return('The price should be a number')
elif isinstance(discount,int) ==False or isinstance(discount,float) ==False:
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')
else:
converted_discount = discount / 100
return (price - converted_discount)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Challenge Information:
Build an Apply Discount Function - Build an Apply Discount Function
Please help. I’ve done all I can to complete this script. I tested it in Python directly and it works perfectly. However, as I “Check your code”, I get an error. Can someone please tell me what I’m doing wrong?
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.
The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.