Python List clear()

Clear() in Python List

 

The clear() method removes all the elements present in a list. Basically it is used to clear the list.

clear() method does not take any parameters.

Python List clear()

Syntax :


myList.clear()


Return Type :

The clear() method does not return any value.


#clear() in python list

myList = [ 12910442 ]
print(myList)

#all the values deleted from list
myList.clear()
print(myList)


Output :

[1, 2, 9, 10, 4, 4, 2]
[]