Tell us what’s happening:
I need help solving steps 3, 4, 5 and 6 of the apply_discount problem. I keep trying different methods but still no solution, even though the outcome is right. S
o can someone please assist by taking a look at my code.
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."
discounted_price = price - (price * (discount / 100))
return discounted_price
print(apply_discount(100, 20))
print(apply_discount(200, 50))
print(apply_discount(50, 0))
print(apply_discount(0, 100))
print(apply_discount(74.5, 20.0))
print(apply_discount('four', 20.5))
print(apply_discount(80, 'six'))
Your browser information:
User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.5 Mobile/15E148 Safari/604.1
Challenge Information:
Build an Apply Discount Function - Build an Apply Discount Function
