Latest web development tutorials

Python3 List pop () method

Python3 list Python3 list


description

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

grammar

pop () method syntax:

list.pop(obj=list[-1])

parameter

  • obj - optional parameter object to remove elements of the list.

return value

This method returns the element object is removed from the list.

Examples

The following example shows the pop () method using the function:

#!/usr/bin/python3

list1 = ['Google', 'w3big', 'Taobao']
list1.pop()
print ("列表现在为 : ", list1)
list1.pop(1)
print ("列表现在为 : ", list1)

Examples of the above output results are as follows:

列表现在为 :  ['Google', 'w3big']
列表现在为 :  ['Google']

Python3 list Python3 list