Open In App
Related Articles

Python List pop() Method

Improve Article
Save Article
Like Article

Python list pop() is an inbuilt function in Python that removes and returns the last value from the List or the given index value.

Python List pop() Method Syntax

Syntax: list_name.pop(index)

  • index (optional) – The value at index is popped out and removed. If the index is not given, then the last element is popped out and removed.

Return: Returns The last value or the given index value from the list.

Exception: Raises IndexError When the index is out of range.

Python List pop() Method Example

Pops and removes the last element from the list using Python.


l = [1, 2, 3, 4]
print("Popped element:", l.pop())
print("List after pop():", l)


Popped element: 4
List after pop(): [1, 2, 3]

Remove Item at specific index from Python List

Pops and removes the 3rd index element from the list.


list1 = [1, 2, 3, 4, 5, 6]
# Pops and removes the 3th index
# element from the list
print(list1.pop(3), list1)


4 [1, 2, 3, 5, 6]

IndexError: pop index out of range


# Python3 program for error in pop() method
list1 = [ 1, 2, 3, 4, 5, 6 ]


Traceback (most recent call last):
File "/home/", line 5, in
IndexError: pop index out of range

Remove Item at Negative index from Python List

Pops and removes 5 elements from the list.


list1 = [1, 2, 3, 4, 5, 6]
poped_item = list1.pop(-2)
print("New list", list1)
print("Poped Item", poped_item)


New list [1, 2, 3, 4, 6]
Poped Item 5

Practical Example

A list of the fruit contains fruit_name and property saying its fruit. Another list consume has two items juice and eat. With the help of pop() and append() we can do something interesting. 


fruit = [['Orange','Fruit'],['Banana','Fruit'], ['Mango', 'Fruit']]
consume = ['Juice', 'Eat']
possible = []
# Iterating item in list fruit
for item in fruit :
    # Iterating use in list consume
    for use in consume :


[['Orange', 'Fruit', 'Juice'], ['Orange', 'Fruit', 'Eat'],
['Banana', 'Fruit', 'Juice'], ['Banana', 'Fruit', 'Eat'],
['Mango', 'Fruit', 'Juice'], ['Mango', 'Fruit', 'Eat']]

Time Complexity : 

The complexity of all the above examples is constant O(1) in both average and amortized case 

Last Updated : 29 Jul, 2023
Like Article
Save Article
Similar Reads
Related Tutorials