tag for deleting a list in python

140

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++']

Comments

Submit
0 Comments