Python List pop() Method

Removes the item that is at the specified position.

Syntax

Python
list.pop(position)

Parameters

ParameterDescription
position Required. The position at which to remove the item, starting at position 0.

Example

Python
groceries = ['apples', 'oranges', 'paper towels']
groceries.pop(1)
print(groceries

Output

['apples', 'paper towels']

Notes

If the list has fewer items than the specified position, Python throws an IndexError exception.

Example

Python
groceries = ['apples', 'oranges', 'paper towels']
groceries.pop(10)

Output

Traceback (most recent call last):
  File "Lists.py", line 2, in <module>
    groceries.pop(10)
IndexError: pop index out of range