Build an Apply Discount Function - Build an Apply Discount Function

Tell us what’s happening:
Describe your issue in detail here.

the code I have written doesn’t want to work at all

Your code so far

def apply_discount(price , discount):
 if not isinstance(price,(int or float)):
    return "The price should be a number."

 if not isinstance(discount,(int or 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."

 discount_result = price * discount/100
 final_price = price - discount_result

 return final_price

print(apply_discount(100,20))
    
    


    

Your mobile information:

XBOOK_12 - Android 14 - Android SDK 34

Challenge: Build an Apply Discount Function - Build an Apply Discount Function

Link to the challenge:

I see this problem more often than I should. An common issue campers have is that they see the period at the end of the sentence and believe it’s part of what should be returned. It is not. None of those phrase end with a period.

So I should not end any of the codes with a period?

The strings should not contain a period

look into the usage of the ‘’‘isinstance’‘’ method, when checking against multiple options

good catch on the periods. but also check your isinstance checks — `(int or float)` actually just evaluates to `int`, so if you pass in a float it’ll fail the validation. needs to be `(int, float)` with a comma instead.