Getting and Removing an Element from a List in Python

If we need to remove an element, but still display its value, we use the pop method. We pass the index of the element we need to its parameter:

pythonlst = [1, 2, 3]
print(lst.pop(0)) # 1

You can also use the pop method to remove the last element from the list. To do this, we simply leave the method parameter empty:

pythonlst = [1, 2, 3]
print(lst.pop()) # 3 print(lst) # [1, 2]
Задание 1

Given a list:

pythonlst = ['a', 'b', 'c', 'd', 'e']

Get the last element into a variable, removing it in the process.

Задание 2

Given a list:

pythonlst = ['a', 'b', 'c', 'd', 'e']

Get the first element into a variable, removing it in the process.

Задание 3

Given a list:

pythonlst = ['a', 'b', 'c', 'd', 'e']

Get the second element into a variable, removing it in the process.