Title | Description | Subjects | Tags | CatalogContent | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
.clear() |
Removes all items from the list. |
|
|
|
The Python .clear()
method removes all items from a list.
list.clear()
The .clear()
method has no parameters.
To remove all items from the grocery
list:
grocery = ['🍉', '🍪', '🥬', '🥕']
grocery.clear()
print(grocery)
# Output: []
To remove all items from the orders
list:
orders = ['daisies', 'periwinkle']
orders.clear()
print(orders)