Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 List remove() Method

Python3 List remove() Method

Python3 Lists The Python3 list


Description

The remove() function removes the first match of a value from a list.

Syntax

remove() method syntax:


list.remove(obj)

Parameters

Return Value

This method has no return value, but removes the first match of the value from the list.

Example

The following example shows how to use the remove() function:

Example

#!/usr/bin/python3

list1

=

[

'Google'

,

'Runoob'

,

'Taobao'

,

'Baidu'

]

list1.

remove

(

'Taobao'

)

print

(

"The list is now: "

,

list1

)

list1.

remove

(

'Baidu'

)

print

(

"The list is now: "

,

list1

)

The output of the above example is:


列表现在为 :  ['Google', 'Runoob', 'Baidu']
列表现在为 :  ['Google', 'Runoob']

Python3 Lists The Python3 list