I have the following list in Python:
x = [[1,2],[3,4],[5,'inf'],[6,7],['nan',10]]
I also have the following index list:
idx = [2,4]
I'm trying to remove the elements from the list x corresponding to the index values in idx
. For that, I did the following:
for i in idx:
del x[i]
I however got the following error:
IndexError: list assignment index out of range
How can I solve this issue?