How to delete all the elements from a list that have their corresponding index in another list?
a = [1,13,15,16,22,70,3]
index_list = [3,6]
So the final list should look like this:
a = [1,13,15,22,70] # because we removed the elements that have their index equal to 3 and 6.
I tried this, but as the length of the list is modified because of the deletion, it destroys the proper removing:
i = 0
while i < len(a):
del a[index_list[i]]
i +=1
if (i < len(a)-1):
index_list[i+1] = index_list[i+1] - 1
And I got an error.
How can I make this work?