Python List clear() Method
Removes all items from the list.
Syntax
Python
Copy Code
list.clear()
Example
Python
Copy Code
groceries = ['apples', 'oranges', 'paper towels'] groceries.clear() print(groceries)
Output
[]
Removes all items from the list.
list.clear()
groceries = ['apples', 'oranges', 'paper towels'] groceries.clear() print(groceries)
[]