Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

tag for deleting a list in python

#original list
programming_languages = ["JavaScript", "Python", "Java", "Python", "C++", "Python"]

#sublist created with list comprehension
programming_languages_updated = [value for value in programming_languages if value != "Python"]


#print original list
print(programming_languages)

#print  new sublist that doesn't contain 'Python'
print(programming_languages_updated)

#output

#['JavaScript', 'Python', 'Java', 'Python', 'C++', 'Python']
#['JavaScript', 'Java', 'C++']
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #tag #deleting #list #python
ADD COMMENT
Topic
Name
4+1 =