Skip to content
List Methods

clear()

Remove all items from the list.

list.clear()

list.clear() removes every element from the list, reducing its length to zero.

This mutation affects all references to the list.

Returns

None — the list is emptied in place.

Try it

Run it and change it
items = ["alpha", "beta", "gamma"]
items.clear()
print("Cleared list:", items)

Worth knowing

  • Slice assignment alternative: del items[:] or items[:] = [] performs the exact same in-place clearing operation.

Related entries