In this tutorial, we are going to learn about how to clear or empty a list of elements in Python.
To clear a list, we can use the built-in
clear() method in Python.
Here is an example, that removes the all elements from a
users = ['john', 'nancy', 'salsa'] users.clear() #clears all elements print(users)
Or we can also use the following slice syntax to do it.
users[:] =