Using Python Solve Last 2 Issues Doc Test Passes Def Supplier Ingredients Chef Ingredient Q37045126

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

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.