Tell us what’s happening:
I can’t pass tests 3-6, I left my if and first elif statements different to show some of the things I’ve tried for tests 3 and 4 since they are basically the same if I’m understanding the problem correctly. Tests 5 and 6 seem to work if I enter values outside of the set out ranges. I’ve spent maybe 3 hours on rereading the course/google/YouTube and I’m at a loss. Is there links to better explanations of how functions and scopes work? Just seems like I’m asking for help to get through every test
Your code so far
def apply_discount (price, discount):
if not isinstance(price,(int,float)):
print('The price should be a number')
elif isinstance(discount,str):
print('The discount should be a number')
elif price <=0:
print('The price should be greater than 0')
elif discount <0 or discount >100:
print('The discount should be between 0 and 100')
else:
apply_discount = price - price * discount / 100
print(apply_discount)
return(apply_discount)
apply_discount(100,20)
apply_discount(200,50)
apply_discount(50,0)
apply_discount(1,100)
apply_discount(74.5,20)
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 a Discount Calculator - Build a Discount Calculator