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, specify the position of the element to be removed. Default value -1, returns the last item.

More Examples

Example

Returns the removed element:

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

Run Instance

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