Python List pop()

In this tutorial, we will see about Python List‘s pop method.Python List pop method is used to remove and return the element at specified index.

Python List insert syntax

here list1 is object of list.

Python List pop example

You can simply use pop method to remove and return element at given index.If you do not pass anyparameter then it will remove and return last element in the list.
Let’s understand this with the help of simple example.

Output:

listOfVehicles: [‘Car’, ‘Cycle’, ‘Truck’] Removed vehicle: Bike
listOfVehicles: [‘Car’, ‘Cycle’] Removed vehicle: Truck

As you can see here, if we do not pass any paramter, then pop method will remove last element from the list.
That’s all about Python List pop method.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *