Tell us what’s happening:
my output is correct, even the error messages. But when I check my code it fails to fulfill the requirements 5 and 6
Your code so far
def apply_discount(price, discount):
print(price, type(price))
print(discount, type(discount))
if not isinstance(price, (int, float)) or type(price) == bool:
return 'The price should be a number'
elif not isinstance(discount,(int, float)) or type(discount) == bool:
return 'The discount should be a number'
elif price<=0:
return'The Price should be greater than 0'
elif discount > 100 or discount < 0:
print('The discount should be between 0 and 100')
else:
discount_amount = discount/100 * price
final_price = price - discount_amount
return final_price
print('Final Price:', final_price)
print(apply_discount(0, 20.0))
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Challenge Information:
Build an Apply Discount Function - Build an Apply Discount Function