The clear method
The clear method removes all elements from the list. We do not specify anything in the method parameter.
Syntax
list.clear()
Example
Let's remove all the items in our list:
lst = ['a', 'b', 'c']
lst.clear()
print(lst)
Result of code execution:
[]
Example
Now let's apply the clear method to an empty list:
lst = []
lst.clear()
print(lst)
After executing the code, the method will also return us an empty list:
[]