I am following the directions as far as I understand and am not sure where I am going wrong. Any help you be appreciated. Thank you in advance.
Your code so far
def apply_discount(price, discount):
if price not int or float:
return 'The price should be a number'
if discount is not int or float:
return 'The discount should be a number'
if price <=0:
return 'The price should be greater than 0'
if discount is <1:
return 'The discount should be between 0 and 100'
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.2 Safari/605.1.15
Challenge Information:
Build a Discount Calculator - Build a Discount Calculator
I was able to get the test for steps 1 and 2 to go through successfully. However from there the tests are failing. Any guidance would be appreciated and I have tried everything that I know how to do. Thank you in advance.
Your code so far
def apply_discount(price, discount):
if not isinstance(price, number):
return 'The price should be a number'
if not isinstance(discount, number):
return 'The discount should be a number'
if price <=0:
return 'The price should be greater than 0'
if discount <1:
return 'The discount should be between 0 and 100'
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.2 Safari/605.1.15
Challenge Information:
Build a Discount Calculator - Build a Discount Calculator
Hello. I have fixed the custom function and I have no error codes but when I call the function it isn’t returning anything. Please help.
Your code so far
def apply_discount(price, discount):
if not isinstance(price, (int,float)):
return 'The price should be a number'
if not isinstance(discount, (int,float)):
return 'The discount should be a number'
if price <=0:
return 'The price should be greater than 0'
if discount <0 or discount >100:
return 'The discount should be between 0 and 100'
apply_discount(100, 20)
apply_discount(200, 50)
apply_discount(50, 0)
apply_discount(100, 0)
apply_discount(74.5, 20.0)
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.2 Safari/605.1.15
Challenge Information:
Build a Discount Calculator - Build a Discount Calculator
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.