Python list clear() method
Remove every item.
Syntax
list.clear()
The list object stays the same, now empty, so other names pointing to it see the change.
Parameters
None.
Return value
None
Example
Code
xs = [1, 2, 3] alias = xs xs.clear() print(xs, alias)
Output
[] []
Related
Learn it step by step in the free lesson Lists & Tuples, with exercises that check your answers.