Python编程 :从入门到实践
第七章 动手试一试
7-8 熟食店
sandwich_orders = ['a','b','c']
finished_sandwiches = []
while sandwich_orders:
sandwich_order = sandwich_orders.pop()
print("I made your" + sandwich_order + " sandwich")
finished_sandwiches.append(sandwich_order)
print(sorted(finished_sandwiches))
7-9 五香烟熏牛肉卖完了
sandwich_orders = ['pastrami','a','pastrami','b','pastrami','c']
print("熟食店的五香烟熏牛肉卖完了。")
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
print(sandwich_orders)
7-10 梦想的度假胜地
wanted_places = {}
prompt = "If you could visit one place in the world,"
prompt += " where would you go?"
active = True
while active:
name = input("What's you name?(Enter 'quit' will exit.) ")
if name == 'quit':
active = False
break
wanted_place = input(prompt)
wanted_places[name] = wanted_place
print(wanted_places)