List Delete: delete one item and delete an entire section : List Remove « List « Python






List Delete: delete one item and delete an entire section

List Delete: delete one item and delete an entire section

L = ['SPAM!', 'eat', 'more', 'please']
del L[0]                       # delete one item
print L

del L[1:]                      # delete an entire section
print L                              # same as L[1:] = []

           
       








Related examples in the same category

1.Deleting List ElementsDeleting List Elements
2.List: delete an elementList: delete an element
3.List: delete a slice :2List: delete a slice :2
4.Delete an element from a listDelete an element from a list