How to Empty List Using Clear() Method in Python


In this example we will show how to empty the list using the clear() method in Python.

Source Code

my_list = ['a', 'b', 'c', 'd', 'e']
my_list.clear()
print(my_list)

Output:

[]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments