AlphaCodingSkills

Python - List clear() Method


Advertisements

The Python list clear() method is used to delete all elements of the specified list.

Syntax


list.clear()

Parameters

No parameter is required.

Example: Clear all elements of a list

In the below example, the list clear() method is used to delete all elements of the list called MyList.

MyList = [10, 50, 50, 100, 1000, 1000]

MyList.clear()      
print(MyList)

Output

[]

Lists Methods