ReferenceList methods
list.clear()
Removes everything, keeping the same list object.
Signature
items.clear()Returns
None.
Example
Python
a = [1, 2]
b = a
a.clear()
print(a, b)Output
[] []
Basics
Strings
Collections
Functions
Classes and objects
Modules and the standard library
Files and errors
Beyond the basics
ReferenceList methods
Removes everything, keeping the same list object.
items.clear()None.
a = [1, 2]
b = a
a.clear()
print(a, b)Output
[] []