Home  >  Article  >  Backend Development  >  What is the usage of remove function in python?

What is the usage of remove function in python?

coldplay.xixi
coldplay.xixiOriginal
2020-06-23 16:12:0332784browse

What is the usage of remove function in python?

What is the usage of remove function in python?

Usage of remove function in python:

Description

remove() function is used to remove a list The first occurrence of a value in .

Syntax

remove() method syntax:

list.remove(obj)

Parameters

obj -- The object to be removed from the list.

Return value

This method has no return value but will remove the first match of a value in the list.

Examples

The following examples show 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']

Recommended tutorial: "python video tutorial"

The above is the detailed content of What is the usage of remove function in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn