23
loading...
This website collects cookies to deliver better user experience
def apply_discount(product, discount):
price = int(product['price'] * (1.0 - discount))
assert 0 <= price <= product['price']
return price
>>> shoes = {'name': 'Fancy Shoes', 'price': 14900}
>>> apply_discount(shoes, 0.25)
>>> apply_discount(shoes, 2.0)
Traceback (most recent call last):
File "<input>", line 1, in <module>
apply_discount(prod, 2.0)
File "<input>", line 4, in apply_discount
assert 0 <= price <= product['price']
AssertionError