python 3.x - how to remove elements from one list if other list contain the indexes of the elements to be removed -
python 3.x - how to remove elements from one list if other list contain the indexes of the elements to be removed -
i have 2 lists - lista = [1,2,3,5,0,5,6,0] listb = [4,7]
listb contains index numbers. how can remove index 4 , 7(contained in lisb) lista.
i want print new_lista [1,2,3,5,5,6]
i hope makes sense.
alwina
use enumerate
:
new_lista = [j i, j in enumerate(lista) if not in listb]
python-3.x
Comments
Post a Comment