VOOZH about

URL: https://www.geeksforgeeks.org/python/python-list-clear-method/

⇱ Python List clear() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python List clear() Method

Last Updated : 27 May, 2026

clear() method is used to remove all elements from a list. It empties the list completely while keeping the original list object unchanged.

In this example, clear() removes all items from the list.


Output
[]

Explanation: clear() removes all elements from list a, making it an empty list.

Syntax

list.clear()

Examples

Example 1: In this example, the list contains sublists. Calling clear() removes all nested elements from the main list.


Output
[]

Explanation: clear() removes all sublists stored inside list a.

Example 2: Here, the list is cleared and then reused to store new values without creating a new list.


Output
[40]

Explanation: After clear() empties the list, append(40) adds a new element to the same list.

Comment