Quick actions

cmd+k|ctrl+k

Navigation

Languages

Apply Discount

Snippet info

Language

Python

Visibility

public

Author

hospino11

Created

2026-07-23T04:44:31.263482Z

Updated

2026-07-23T04:49:12.687171Z

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"

    total_discount = price * discount / 100

    return price - total_discount
    
print(f"{apply_discount('fifty', 10)}")
INFO