【Python】练习 7.8:熟⾷店 创建⼀个名为 sandwich_orders 的列表,其中 包含各种三明治的名字,再创建⼀个名为 finished_sandwiches 的空列表。

练习 7.8:熟⾷店 创建⼀个名为 sandwich_orders 的列表,其中 包含各种三明治的名字,再创建⼀个名为 finished_sandwiches 的空列表。

要求

  1. 遍历列sandwich_orders,对于其中的每种三明治, 都打印⼀条消息,如“I made your tunasandwich.”,并将其移到列表 finished_sandwiches 中。
  2. 当所有三明治都制作好后,打印⼀条消息,将这些三明治列出来。

代码

 sandwich_orders = ['臭豆腐三明治', '皮蛋三明治', '无花果三明治']
finished_sandwiches = []
while len(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}")

打印

三明治

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值