What is the usage of remove function in python?

coldplay.xixi
Release: 2020-06-24 09:04:07
Original
32860 people have browsed it

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;
Copy after login

The output results of the above examples are as follows:

List :  [123, 'zara', 'abc', 'xyz']
List :  [123, 'zara', 'xyz']
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template