Last active
August 14, 2018 16:58
-
-
Save alairock/1e222f30b75531e4dd74b3b79e0c2533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# Everyone in queue, and their desired order | |
customers = [('Bob', 'Ham Sandwich'), ('Paul', 'Grilled Cheese'), ('Sally', 'Chicken Croissant')] | |
# make a sandwich, but pause(yield) to deliver it | |
def make_sandwiches(): | |
for customer in customers: | |
time.sleep(1) # making the sandwich for our customer | |
yield (customer[0], customer[1]) | |
sandwiches = make_sandwiches() | |
# deliver the sandwiches | |
for sandwich in sandwiches: | |
print('Delivering sandwich:', sandwich[1], 'for', sandwich[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment