当前位置 : 主页 > 编程语言 > python >

Python-while(列表)

来源:互联网 收集:自由互联 发布时间:2022-06-15
""" Author:Zhou Create_Date:2022年06月07日--07:50 Tool:PyCharm Software: PyCharm """ sandwich_orders = ['pastrami', 'orange', 'banana', 'pastrami', 'strawberry', 'pastrami'] finished_sandwich = [] print('I made your tuna sandwich')
"""
Author:Zhou
Create_Date:2022年06月07日--07:50
Tool:PyCharm
Software: PyCharm
"""
sandwich_orders = ['pastrami', 'orange', 'banana', 'pastrami', 'strawberry', 'pastrami']
finished_sandwich = []
print('I made your tuna sandwich')
"""while sandwich_orders:
sandwich = sandwich_orders.pop()
finished_sandwich.append(sandwich)

print(finished_sandwich)"""
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
print('pastrami is sold out')
while sandwich_orders:
sandwich = sandwich_orders.pop()
finished_sandwich.append(sandwich)
print('finshed_sandwich:'+str(finished_sandwich))
网友评论