Tell us what’s happening:
I’m currently stuck because I don’t know why my function doesn’t return the necessary result, which would be the string “The discount should be between 0 and 100” when the discount is 0. All the other tests pass, can anyone help me? Thanks a lot.
Your code so far
def apply_discount(price, discount):
if not isinstance(price,(float,int)) or isinstance(price, bool):
return "The price should be a number"
elif not isinstance(discount,(float,int)) or isinstance(discount, bool):
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:
mount_discount = price * (discount/100)
total = price - mount_discount
return total
apply_discount(50, 0) should return 50.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 Edg/151.0.0.0
Challenge Information:
Build an Apply Discount Function - Build an Apply Discount Function