“Remova a lista de valor da lista python” Respostas de código

Remova a lista de valor da lista python

# Python program to remove multiple
# elements from a list
 
# creating a list
list1 = [11, 5, 17, 18, 23, 50]
 
# items to be removed
unwanted_num = {11, 5}
 
list1 = [ele for ele in list1 if ele not in unwanted_num]
 
# printing modified list
print("New list after removing unwanted numbers: ", list1)
Confused Crocodile

Remova a lista de valor da lista python

# Python program to remove multiple
# elements from a list
 
# creating a list
list1 = [11, 5, 17, 18, 23, 50]
 
# given index of elements
# removes 11, 18, 23
unwanted = [0, 3, 4]
 
for ele in sorted(unwanted, reverse = True):
    del list1[ele]
 
# printing modified list
print (*list1)
Confused Crocodile

Respostas semelhantes a “Remova a lista de valor da lista python”

Perguntas semelhantes a “Remova a lista de valor da lista python”

Mais respostas relacionadas para “Remova a lista de valor da lista python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código