Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python List remove() method

Python List remove() method

Python Lists Python Lists


Description

The remove() function removes the first match of a value from a list.

Syntax

remove() method syntax:



list.remove(obj)

Parameters

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 Python Lists