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.

💻 Awesome Tech Resources:
  • Looking for ⚒️ tech jobs? Go to our job portal.
  • Looking for tech events? Go to tech events 🗓️ Calendar.️

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.

Related Posts

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.