.clear()

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:

Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy

Edit this page on GitHub

Contributors