Jan-30-2019, 04:13 PM
Hi, i have a problem with this python code that should not create an infinite loop. This code should take one item from one list, print a message using that item and then add it to another list.At the end of the program all the items in the second list should be printed.
sandwich_orders = ['halumi', 'tuna', 'ham and cheese', 'salami', ] finished_sanwiches = [] while sandwich_orders: sandwich_ordered = sandwich_orders.pop() print("\nMaking your " + sandwich_ordered.title() + " sandwich.") sandwich_orders.append(sandwich_ordered) print("\n===This sandwiches have been finished making.===") for sandwich in finished_sanwiches: print(sandwich.title())What the program does:
Error:Making your Salami sandwich.
Making your Salami sandwich.
Making your Salami sandwich.
Making your Salami sandwich.
Making your Salami sandwich.
Making your Salami sandwich.
Making your Salami sandwich.
-this continues to infinity-