Tell us what’s happening:
When I run the test, it says my code is incorrect
So This is my code thus far and I have checked the function for every possible combination of inputs and it works perfectly but when I hit the run the tests button, it says the code is wrong from step 3 onwards. Step 3 is when apply_discount is called with price that is not a number it should return the price should be a number which my code does. Any help would be appreciated. Thanks!
Your code so far
def apply_discount(price, discount):
if not isinstance(price, (int, float)):
return print('The price should be a number')
elif not isinstance(discount, (int, float)):
return print('The discount should be a number')
elif price <= 0:
return print('The price should be greater than 0')
elif discount < 0 or discount > 100:
return print('The discount should be between 0 and 100')
else:
final_price = price - (discount/100)*price
return print(final_price)
apply_discount(100, 20)
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 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0
Challenge Information:
Build a Discount Calculator - Build a Discount Calculator
