Python List pop() Method
Example
Remove the second element of the fruit
list:
fruits = ['apple', 'banana', 'cherry']
fruits.pop(1)
Run example »
Definition and Usage
The pop()
method removes the element at the
specified position.
Syntax
list.pop(pos)
Parameter Values
Parameter | Description |
---|---|
pos | Required. A number specifying the position of the element you want to remove |
More Examples
Example
Return the removed element:
fruits = ['apple', 'banana', 'cherry']
x =
fruits.pop(1)
Run example »
Note: The pop()
method
returns removed value.