Created
April 15, 2017 17:05
-
-
Save venkatsgithub1/4788ae906f9d620021c60bb2b4927c23 to your computer and use it in GitHub Desktop.
Python | Using del function to remove data from list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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