The del statement removes elements by index or slice. Given nums = [0, 1, 2, 3, 4], del nums[2] removes index , leaving [0, 1, 3, 4]. Delete a range with slices: del nums[1:3] removes indices and .
You can even delete the entire list: del nums removes the variable entirely. The clear() method empties a list while keeping the variable: nums.clear() leaves an empty list [].
This differs from del nums because the variable still exists. Use del for surgical removal of specific positions, and clear() when you want to reset a list to empty for reuse.