collection data types deleting items using the del statement although the name of the del statement is reminiscent of the word deleteit does not necessarily delete any data when applied to an object reference that refers to data item that is not collectionthe del statement unbinds the object reference from the data item and deletes the object reference for examplex object ref 'xcreatedint of value created del object ref 'xdeletedint ready for garbage collection traceback (most recent call last)nameerrorname 'xis not defined when an object reference is deletedpython schedules the data item to which it referred to be garbage-collected if no other object references refer to the data item whenor even ifgarbage collection takes place may be nondeterministic (depending on the python implementation)so if any cleanup is required we must handle it ourselves python provides two solutions to the nondeterminism one is to use try finally block to ensure that cleanup is doneand another is to use with statement as we will see in when del is used on collection data type such as tuple or listonly the object reference to the collection is deleted the collection and its items (and for those items that are themselves collectionsfor their itemsrecursivelyare scheduled for garbage collection if no other object references refer to the collection for mutable collections such as listsdel can be applied to individual items or slices--in both cases using the slice operator[if the item or items referred to are removed from the collectionand if there are no other object references referring to themthey are scheduled for garbage collection we could use this technique to increment all the numbers in list of integers for examplefor in range(len(numbers))numbers[ + since lists support slicingin several cases the same effect can be achieved using either slicing or one of the list methods for examplegiven the list woods ["cedar""yew""fir"]we can extend the list in either of two wayswoods +["kauri""larch"woods extend(["kauri""larch"]