Python List clear() Method

28 Jun 2025 | 3 min read

The Python list clear() method removes all the elements from the list. It clear the list completely and returns nothing. It does not require any parameter and returns no exception if the list is already empty.

Syntax of the clear() Method in Python List

The following is the syntax of the list clear() method:

Syntax:

Parameter:

  • No parameter

Return:

  • It returns None.

Examples of List clear()

Let's see some examples of list clear() method to understand it's functionality.

Example 1: Simple Use of the List clear() Method

Let's see a simple example in which clear() method is used to clear a list. The clear() method clears all the elements from the list.

Output:

 Given List: ['1', '2', '3'] Updated List: [] 

Explanation:

In the above example, we are given a list. We used the clear() method to remove all the elements from the list. As a result, the list becomes empty.

Example 2: Clearing an Empty List

If the list is already empty, the method returns nothing. See the example below.

Output:

 Given List: [] Updated List: [] 

Explanation:

In this example, we are given an empty list. We used the clear() method to clear the list. Since, the list is already empty, there is no impact on the list after using clear(). Hence, it returns nothing.

Conclusion

Python contains different built-in methods and functions that help developers to easily create flawless software. The Python list clear() method is extremely useful in situations where we want to quickly empty the list. This tutorial has covered all the details and examples regarding this method, but don't limit yourself to these examples; instead, try more and more examples to be proficient.

Python List clear() Method FAQs

1) What is the purpose to use clear() method in Python? Demonstrate this using an example

The clear() method is used to remove all the elements from the list..

The syntax of the clear() is as follows:

Syntax:

Output:

 Original List: ['1', '2', '3'] List after Clearing the elements: [] 

2) What does the clear() method returns?

The clear() method returns none. It only removes all the elements from the existing list.

3) What will happen if we apply clear() method on an empty list?

If we apply clear() method on an empty list, nothing happens. The original list is empty or it will remain empty.

4) Does clear() delete the list itself?

No, clear() removes the elements inside the list, but the list object still exists.

5) Can clear() be used on other data types like strings or tuples?

No, clear() is only available for lists, dictionaries, sets, etc. Immutable types like strings and tuples don't support it.