Easy Tutorial
❮ Ref Math Log2 Python Os Path ❯

Python3 List pop() Method

Python3 List


Description

The pop() function is used to remove an element from the list (by default, the last element) and return the value of that element.

Syntax

Syntax for the pop() method:

list.pop([index=-1])

Parameters

Return Value

This method returns the element object removed from the list.

Example

The following example demonstrates the use of the pop() function:

#!/usr/bin/python3

list1 = ['Google', 'tutorialpro', 'Taobao']
list1.pop()
print("The list is now: ", list1)
list1.pop(1)
print("The list is now: ", list1)

The output of the above example is as follows:

The list is now:  ['Google', 'tutorialpro']
The list is now:  ['Google']

Python3 List

❮ Ref Math Log2 Python Os Path ❯