Home >>Python List Methods >Python List clear() Method

Python List clear() Method

Python List clear() Method

Python list clear() method is used to remove all the elements from the given input list.

Syntax:
list.clear()
Here is an example of Python clear() method:

fruits = ["apple", "banana", "orange", "mango"]
fruits.clear()
print(fruits)

Output:
[]
Example 2

fruits = ["Python", "PHP", "Java"]
fruits.clear()
print(fruits)

Output:
[]

No Sidebar ads