Reference Materials
Certification Courses
Created with over a decade of experience and thousands of feedback.
Python List clear()
In this tutorial, we will learn about the Python List clear() method with the help of examples.
The clear() method removes all items from the list. Here's a quick example:
models = ['Claude', 'ChatGPT', 'Gemini', 'ChatGPT']
models.clear()
print(models)
Output
[]
clear() Syntax
The syntax of clear() is:
my_list.clear()
Arguments
clear() doesn't take any arguments.
Return Value
clear() doesn't return any value (returns None).
Example: Clear a List with Nested Items
models = [("Claude", 2023), ("DeepSeek", 2025)]
models.clear()
print(models)
Output
[]
Example: Emptying a List Using del
We can also empty a list using the del statement.
models = ['Claude', 'ChatGPT', 'Gemini', 'ChatGPT']
del models[:]
print(models)
Output
[]
Here, models[:] selects all items in the list from beginning to end, and the del keyword deletes these items.
To learn more, visit Python del statement.
Also Read:
Did you find this article helpful?