创建一个名为sandwich_orders 的列表,在其中包含各种三明治的名字;再创建一个名为finished_sandwiches 的空列表。遍历列 表sandwich_orders ,对于其中的每种三明治,都打印一条消息,如I made your tuna sandwich ,并将其移到列表finished_sandwiches 。所有三明 治都制作好后,打印一条消息,将这些三明治列出来。
sandwhich_orders = ['tuna', 'strawberry', 'apple', 'bacon', 'egg']
finished_sandwhiches = []
while sandwhich_orders:
sandwhich = sandwhich_orders.pop()
finished_sandwhiches.append(sandwhich)
print("I made your "+sandwhich+" sandwhich")
print("\nThe sandwhich_orders is:")
print(finished_sandwhiches)