Python3 List remove() Method
Description
The remove() function is used to remove the first occurrence of a value in a list.
Syntax
Syntax of the remove() method:
list.remove(obj)
Parameters
- obj -- The object to be removed from the list.
Return Value
This method does not have a return value, but it removes the first occurrence of a value in the list.
Example
The following example demonstrates how to use the remove() function:
Example
#!/usr/bin/python3
list1 = ['Google', 'Example', 'Taobao', 'Baidu']
list1.remove('Taobao')
print ("The list is now : ", list1)
list1.remove('Baidu')
print ("The list is now : ", list1)
list1 = ['Google', 'Example', '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 as follows:
列表现在为 : ['Google', 'Example', 'Baidu'] 列表现在为 : ['Google', 'Example']Other Extensions
Python3 List