Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 705 Bytes

File metadata and controls

49 lines (35 loc) · 705 Bytes
Title Description Subjects Tags CatalogContent
.clear()
Removes all items from the list.
Data Science
Computer Science
Lists
Methods
learn-python-3
paths/data-science
paths/computer-science

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:

orders = ['daisies', 'periwinkle']

orders.clear()

print(orders)