sandwich_orders = [ 'wrap','toast' ,'regular veg' , 'cheese_toast' , 'cheese_veg', 'big cheese toast' , 'big cheese veg']
finished_sandwiches = []
current_active = True
while current_active:
current_sandwich = sandwich_orders.pop(0)
print("\nVerifying your order, " + current_sandwich.title())
finished_sandwiches.append(current_sandwich)
print("These are your finished sandwiches")
for finished_sandwich in finished_sandwiches:
print ("\nHere is your sandwich " + finished_sandwich.title())
答案 0 :(得分:0)
这是一个无限循环,可以通过在列表为空时停止来解决。 为此,只需在sandwich_orders的大小为0时将current_active设置为False。