Because lists are mutable, you can use the del statement to delete an item or section in place:
L = ['test', 'eggs', 'ham', 'toast'] del L # Delete one item print( L ) del L[1:] # Delete an entire section print( L ) # Same as L[1:] =  # from w ww . j a v a 2 s .c o m
Because slice assignment is a deletion plus an insertion, you can delete a section of a list by assigning an empty list to a slice (L[i:j]=).
Python deletes the slice named on the left, and then inserts nothing.
Assigning an empty list to an index just stores a reference to the empty list object in the specified slot, rather than deleting an item:
L = ['Already', 'got', 'one'] L[1:] =  # from w ww.j av a 2s .c o m print( L ) L =  print( L )