Python List pop() Method

Example

Delete the second element of the fruits list:

fruits = ['apple', 'banana', 'cherry']
fruits.pop(1)

Run Instance

Definition and Usage

The pop() method deletes the element at the specified position.

Syntax

list.pop(pos)

Parameter Value

Parameter Description
pos Optional. Number, specifies the position of the element to be removed. The default value is -1, which returns the last item.

More Examples

Example

Return the removed element:

fruits = ['apple', 'banana', 'cherry']
x = fruits.pop(1)

Run Instance

Note:The pop() method returns the value that was removed.