Apr-24-2020, 12:29 PM
I have written some simple code that should read a list and return a result for each item in the list
the output comes back as:-
The chopped pork is ready for collection
The beef is ready for collection
The cheese is ready for collection
The jam buttie is ready for collection
['chopped pork', 'beef', 'cheese', 'jam buttie']
[Finished in 0.1s]
sandwich_orders = ['jam buttie','pastrami','cheese','pastrami','beef', 'chopped pork','pastrami'] finished_orders = [] print("Sorry we have run out of pastrami") while 'pastrami' in sandwich_orders: sandwich_orders.remove ('pastrami') while sandwich_orders: finished_order = sandwich_orders.pop() print(f"The {finished_order} is ready for collection") finished_orders.append(finished_order) print (finished_orders)every thing is reversed i have found i could use lst.reverse() but i dont want to reverse the list just to make it read from beginning to end.
the output comes back as:-
The chopped pork is ready for collection
The beef is ready for collection
The cheese is ready for collection
The jam buttie is ready for collection
['chopped pork', 'beef', 'cheese', 'jam buttie']
[Finished in 0.1s]