Hello! I am having an issue getting the equation to work on this one
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):
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:
return(price*discount)/100
print(apply_discount)
price = 20
discount = 100
apply_discount(100, 200)
apply_discount(200, 50)
apply_discount(50, 0)
apply_discount(100, 100)
apply_discount(74.5, 20.0)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
Challenge Information:
Build an Apply Discount Function - Build a Discount Calculator
Price and discount values are passed to the function when you call it, so there is no need to create global variables for those.
You are trying to print a call to apply_discount inside the function itself.
Instead, wrap each of the test function calls in the global space inside a print() so you can see what your function returns and compare to what the corresponding test expects.
Does this validation check meet the requirement of User Story #4?
Does this validation check meet the requirement of User Story #6?
What do you see in the console? Does it make sense to have a final price of 0 if the price is 50 and the discount is 0%? Or a final price of 100 if the price is 100 and the discount is 100%?
You need to rework your algorithm for the final price.
you did not follow the advice about checking the returned value of the function, now you have removed the return instead, so what is your function returning?
I see what you mean, I returned instead of printed and it’s no longer returning NONE, but I’m still getting negatives. Is there a way I can define the discount_amount without breaking the equation?
hahaaaaaa, once again a duh moment. Thank you for the help! I have a feeling this profession is going to continuously humble me but I enjoy the process