In this lesson, we will focus on Python list pop method. We will learn how to remove any member of a list in python. We can do this with python pop method and the index of the list member. You can also check python list append method to see how to add a new member at the end of a list.
Let’s show how can we use python pop method for python list pop.
With this example, we will remove the third member of the list (index = 2). Remember, the indexes starts from 0 and continues as 1,2,3 etc. So the first member has index 0, the second memebr has index 1 and the third member has index 2. Here, we will remove third member, index 2. So, the output of this python code will be:
We can also assign the removed member to a variable and then we can print it like below:
The output of this code will be the removed member:
Let’s do the similar examples with number lists.
As an output, the fourth member of the list (index=3), “76”, will be removed.
Here, we have used python pop () method for Python list pop function. You can use this method for your various python codes related with lists.