.clear()
Anonymous contributor
Anonymous contributor3071 total contributions
Anonymous contributor
Published May 5, 2021Updated Sep 3, 2021
Contribute to Docs
The Python .clear()
method removes all items from a list.
Syntax
list.clear()
The .clear()
method has no parameters.
Example
To remove all items from the grocery
list:
grocery = ['🍉', '🍪', '🥬', '🥕']grocery.clear()print(grocery)# Output: []
Codebyte Example
To remove all items from the orders
list:
All contributors
- Anonymous contributorAnonymous contributor3071 total contributions
- christian.dinh2476 total contributions
- Anonymous contributor
- christian.dinh
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.