In actual work, we will maintain the background, but it is unrealistic to open the background editor to retrieve and maintain it. For example, to remove the value of a Python list item, what method should be used? The most effective and speedy article, you will learn Removing the value of a Python list itemUsing the Python remove() method is the most effectiveFruit!
For Python remove () Description of method :
remove() function is used to remove the first match of a value in the list.
remove() method syntax:
list.remove(obj)
obj -- The object to be removed from the list.
And because it is removing, this method has no return value
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 results of the above examples are as follows:
List : [123, 'zara', 'abc', 'xyz'] List : [123, 'zara', 'xyz']
In-class extension:
The above is the detailed content of How to remove the value of a Python list item Python remove() method is most effective. For more information, please follow other related articles on the PHP Chinese website!