7 lines
271 B
Python
7 lines
271 B
Python
def discount_price(price: float, discount: float) -> float:
|
|
if price < 0:
|
|
raise ValueError("price cannot be negative")
|
|
if not 0 <= discount <= 100:
|
|
raise ValueError("discount must be between 0 and 100")
|
|
return price - (price * discount / 100)
|