A bottle holds ml millilitres of water, and each sip takes sip millilitres. Finish drink(sip) in Bottle: take the sip out of the bottle; if there isn't enough, the bottle ends at 0, never below.
water_left(500, [100, 150])→250water_left(300, [200, 200])→0class Bottle:
def __init__(self, ml):
self.ml = ml
def drink(self, sip):
# your code here: take away the sip; if it goes below 0, set it to 0
pass
def water_left(ml, sips):
bottle = Bottle(ml)
for sip in sips:
bottle.drink(sip)
return bottle.ml
Run tries the examples. When they look right, Submit.