Open In App

Python List pop() Method

Last Updated : 11 Sep, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

pop() method removes and returns an element from a list. By default, it removes the last item, but we can specify an index to remove a particular element. It directly modifies the original list.

Let's take an example to remove an element from the list using pop():

Python
a = [10, 20, 30, 40]

a.pop()

print(a)

Output
[10, 20, 30]

Explanation: a.pop() removes the last element, which is 40. The list a is now [10, 20, 30].

Syntax:

list.pop(index)

Parameters:

  • index (optional): index of an item to remove. Defaults to -1 (last item) if argument is not provided.

Return Type:

  • Returns the removed item from the specified index
  • Raises IndexError if the index is out of range.

Examples of pop() Method

Example 1: Using pop() with an index

We can specify an index to remove an element from a particular position (index) in the list.

Python
a = ["Apple", "Orange", "Banana", "Kiwi"]

val = a.pop(2)

print(val)
print(a)

Output
Banana
['Apple', 'Orange', 'Kiwi']

Explanation:

  • a.pop(2) removes the element at index 2, which is "Banana".
  • val stores the value Banana.

Example 2: Using pop() without an index

If we don't pass any argument to the pop() method, it removes the last item from the list because the default value of the index is -1.

Python
a = [10, 20, 30, 40]

val = a.pop()

print(val)
print(a)

Output
40
[10, 20, 30]

Explanation:

  • a.pop() removes the last element, which is 40.
  • val stores the value 40.

Example 3: Handling IndexErrors

The pop() method will raise an IndexError if we try to pop an element from an index that does not exist. Let’s see an example:

Python
a = [1, 2, 3]
a.pop(5)

Output:

IndexError: pop index out of range

Explanation:

  • list a has only three elements with valid indices 0, 1, and 2.
  • Trying to pop from index 5 will raise an IndexError.
  • Python - Remove first element of list
  • Python - Remove rear element from list
  • Python | Remove given element from the list