遍历列sandwich_orders,对于其中的每种三明治, 都打印⼀条消息,如“I made your tunasandwich.”,并将其移到列表 finished_sandwiches 中。
当所有三明治都制作好后,打印⼀条消息,将这些三明治列出来。
代码
sandwich_orders =['臭豆腐三明治','皮蛋三明治','无花果三明治']
finished_sandwiches =[]whilelen(sandwich_orders)>0:# 判断列表是否为空print(f"I made your {sandwich_orders[0]}")
finished_sandwiches.append(sandwich_orders[0])# 制作完的三明治添加到finish
sandwich_orders.remove(sandwich_orders[0])for finished_sandwich in finished_sandwiches:print(f"This is your {finished_sandwich}")