pop() can be used to remove and retrieve arbitrary elements from a list:
s.pop(i) remove and return item at index āiā
s.pop() the default is the last element.
Example:
>>> shopping_list
['milk', 'egg', 'butter', 'cheese', 'bread', 'bananas']
>>> cart = []
>>> item = shopping_list.pop(1)
>>> item
'egg'
>>> cart.append(item)
>>> cart
['egg']
>>> shopping_list
['milk', 'butter', 'cheese', 'bread', 'bananas']
>>> cart.append(shopping_list.pop())
>>> cart
['egg', 'bananas']
>>> shopping_list
['milk', 'butter', 'cheese', 'bread']