7-8 熟食店
三名治的名字可以参考该网站:list of sandwiches
# 熟食店
sandwich_orders = ['bacon', 'barbecue', 'bauru', 'tuna']
finished_sandwiches = []
while sandwich_orders:
sandwich = sandwich_orders.pop()
print("I made your " + sandwich + " sandwich.")
finished_sandwiches.append(sandwich)
print(finished_sandwiches)
7-9 五香烟熏牛肉
# 熟食店
# 五香烟熏牛肉卖完了
sandwich_orders = ['bacon', 'pastrami', 'barbecue', 'pastrami', 'bauru', 'tuna', 'pastrami']
finished_sandwiches = []
print("Pastrami sold out")
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
while sandwich_orders:
sandwich = sandwich_orders.pop()
print("I made your " + sandwich + " sandwich.")
finished_sandwiches.append(sandwich)
print(finished_sandwiches)
7-10 梦想的度假胜地
# 梦想的度假胜地
places = {}
active = True
while active:
name = input("\nWhat is your name? ")
place = input("If you could visit one place in the world, where would " +
"you go? ")
places[name] = place
repeat = input("Would you like to let another person respond? (yes/no) ")
if repeat == 'no':
active = False
print("\n--- Poll Results ---")
for name, place in places.items():
print(name.title() + " want visit " + place.title() + ".")