Skip to content

Instantly share code, notes, and snippets.

@venkatsgithub1
Created April 15, 2017 17:05
Show Gist options
  • Save venkatsgithub1/4788ae906f9d620021c60bb2b4927c23 to your computer and use it in GitHub Desktop.
Save venkatsgithub1/4788ae906f9d620021c60bb2b4927c23 to your computer and use it in GitHub Desktop.
Python | Using del function to remove data from list.
#Usage of delete method to remove elements from list.
list_of_items=["Watch", "Headphones", "Mobile Phone", "Laptop"]
"""
*****************************
delete method takes element
in the following format:
del (list[n])
where list is the name of the
list, n is the index of the
item in the list.
Like remove function, del
function doesn't return
back anything.
*****************************
After below delete usage on
list_of_items, the list is
left with:
['Watch', 'Mobile Phone', 'Laptop']
with Headphones at index 1 removed.
"""
del (list_of_items[1])
print (list_of_items)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment