I'm trying to delete multiple elements from a list. The elements are having their indexes evaluated dynamically, and stored in a list called "dstry". It may look something like this:
arr = [1, 2, 2, 3, 5, 6, 7, 8, 9, 2]
dstry = [1, 2, 9]
However, if I do...
for i in dstry:
del arr[i]
The list begins to shrink, and dstry
's target elements are no longer where they should be.
Logically, how can I get around this? It'd be nice if the del could resolve all at once and delay the collapse of the array. Should I instead replace the elements with a flag value and then del them wherever they appear later so that index is not a factor?
Thanks