+2 votes
in Programming Languages by (12.5k points)
How to delete all elements from a list?

1 Answer

0 votes
by (22.3k points)
edited by

To delete all items from a list, you can use del statement or clear().

Approach 1 (Python 3 only)

a=[11,12,13,14,15,16]
a.clear()
print(a)

[]

Approach 2 (both Python 2 and 3)

a=[11,12,13,14,15,16]
del a[:]
print(a)

[]

...