Python List remove() method
Description
The remove() function removes the first match of a value from a list.
Syntax
remove() method syntax:
list.remove(obj)
Parameters
- obj -- the object to remove from the list.
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:
#!/usr/bin/python
aList = [123, 'xyz', 'zara', 'abc', 'xyz'];
aList.remove('xyz');
print "List : ", aList;
aList.remove('abc');
print "List : ", aList;
The output of the above example is:
List : [123, 'zara', 'abc', 'xyz']
List : [123, 'zara', 'xyz']
Python Lists