This post will discuss how to remove all items from the list in Python. In other words, empty or delete a list in Python.

1. Using list.clear() function

list.clear() is the recommended solution in Python 3 to remove all items from the list.

Download  Run Code

2. Using Slice assignment

You can empty the list by replacing all the elements with an empty list.

But simply doing a = [] won’t clear the list. It just creates a new list and binds it to the variable a, but the old list and its references remain in memory. For instance,

Download  Run Code

 
You can clear the entire list by assignment of an empty list to the slice, i.e., a[:] = [].

Download  Run Code

3. Using del statement

You can also use the del statement to delete the contents of an entire list. This is demonstrated below:

Download  Run Code

That’s all about removing all items from a list in Python.