python:五香烟熏牛肉(pastrami)卖完了,练习编程题

阅读: 评论:0

python:五香烟熏牛肉(pastrami)卖完了,练习编程题

python:五香烟熏牛肉(pastrami)卖完了,练习编程题

创建的列表 sandwich_orders ,并确保 'pastrami' 在其中至少出现了三次。在程序开头附近添加 这样的代码:打印一条消息,指出熟食店的五香烟熏牛肉卖完了;再使用一个 while 循环将列表 sandwich_orders 中的 'pastrami' 都删除。确认最终的列 表 finished_sandwiches 中不包含 'pastrami' ——————————————————————————————————————代码如下:
sandwich_orders = ['bacon_egg_sandwich', 'ham_egg_sandwich', 'lettuce_ham_egg_sandwich']
# count = len(sandwich_orders)
# finished_sandwich = []
# while count > 0:
#     finish_sandwich = sandwich_orders.pop()
#     finished_sandwich.append(finish_sandwich)
#     print('I made your %s sandwich!' %(finish_sandwich))
#     count -= 1
# print(finished_sandwich)
# print(sandwich_orders)
count = 0
finished_sandwich = []
active = True
while active:if count < 3:sandwich_orders.append('pastrami')count += 1if 'pastrami' in sandwich_orders:ve('pastrami')finished_sandwich.append(sandwich_orders.pop())if len(sandwich_orders) == 0:break
print(finished_sandwich)

本文发布于:2024-02-02 23:12:23,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170688674047078.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:牛肉   香烟   卖完   python   pastrami
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23