Python List pop() Syntax

list_name.pop(index)

Parameter

  • index (optional) – The value at the index is popped out and removed. If the index is not given, then the last element is popped out and removed.

Return

Returns The last value or the given index value from the list.

Exception:pop() method raises IndexError when the index is out of range.

Python List pop() Method

Python list pop() function removes elements at a specific index from the list.

Example

Python




fruits = ["apple", "mango", "cherry"]
fruits.pop()
print(fruits)


Output:

['apple', 'mango']

Similar Reads

Python List pop() Syntax

...

What is the List pop method()?

list_name.pop(index)...

How to Use List pop() Method in Python?

pop() function removes and returns the value at a specific index from a list. It is an inbuilt function of Python....

More List pop() Examples

You can easily use pop() function in Python. Using the list pop() method you can remove an element from the list. Let’s understand it with an example:...