using python solve the last 2 issues so that the doc testpasses.
def supplier(ingredients, chef):
for ingredient in ingredients:
try:
chef.send(ingredient)
except StopIteration as e:
print(e)
break
chef.close()
def customer():
served = False
while True:
try:
dish = yield
print(‘Yum! Customer got a {}!’.format(dish))
served = True
except GeneratorExit:
if not served:
print(‘Customer never got served.’)
raise
def chef(customers, dishes):
“””
>>> cust = customer()
>>> next(cust)
>>> c = chef({cust: ‘hotdog’}, {‘hotdog’: [‘bun’,’hotdog’]})
>>> next(c)
>>> supplier([‘bun’, ‘hotdog’], c)
Yum! Customer got a hotdog!
Chef went home.
>>> cust = customer()
>>> next(cust)
>>> c = chef({cust: ‘hotdog’}, {‘hotdog’: [‘bun’,’hotdog’]})
>>> next(c)
>>> supplier([‘bun’], c)
Chef went home.
Customer never got served.
>>> cust = customer()
>>> next(cust)
>>> c = chef({cust: ‘hotdog’}, {‘hotdog’: [‘bun’,’hotdog’]})
>>> next(c)
>>> supplier([‘bun’, ‘hotdog’, ‘mustard’], c)
Yum! Customer got a hotdog!
No one left to