Python list clear

In this article, you’ll see how to clear a list in Python. The clear method is used to delete all the elements of a list. I highly recommend you get the “Python Crash Course Book” to learn Python.

a = [5, 8, 10, 15, 20]
a.clear()
print(a)

Output:

[]

Leave a Comment

Your email address will not be published.