Tell us what’s happening:
I think that I met all the criteria yet I cannot seem to pass no. 3, no.4. Does it have something to do with me using “else” as the means of saying “The price should be a number”?
Your code so far
def apply_discount(price, discount):
if not isinstance(price, (str, bool)):
if price <= 0:
return('The price should be greater than 0')
else:
return("The price should be a number")
if not isinstance(discount, (str, bool)):
if discount < 0 or discount > 100:
return('The discount should be between 0 and 100')
else:
return("The discount should be a number")
if price and (discount < 100) >= 0:
add = price - price * discount/100
return add
print(apply_discount("one", 49))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build an Apply Discount Function - Build an Apply Discount Function