Python List pop() Method (original) (raw)

Last Updated : 11 Sep, 2025

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)

`

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

Syntax:

list.pop(index)

**Parameters:

**Return Type:

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:

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)

`

**Explanation:

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: