xxxxxxxxxx
l = [1, 2, 3] # your list
for idx, _ in enumerate(l):
del l[idx]
# OR
l.clear()
xxxxxxxxxx
# this clear whole elements from list
thislist = ["apple", "banana", "cherry"]
thislist.clear()
xxxxxxxxxx
characters = ["Eren Yeager", "Mikasa Ackerman", "Armin Arlert"]
del characters[:]
print(characters)
xxxxxxxxxx
#a list of strings
mylist = ['Python', 'Java', 'C++', 'Ruby']
#remove all elements from the list
mylist.clear()
#the list is now empty
print(mylist)