So I have a list
a_list = [0,3,4,7,9,11,15]
and a list of outliers
outliers = [0,3,4]
The outliers is the list of indexes that need to be removed from a_list
So in this case, remove the elements in index 0, 3, 4 from a_list. Result should be:
remove these = [0,7,9]
a_list = [0,3,4,11,15]
If I use the del method, the index will change so once I remove 0th index, I will still remove the 3rd index but instead remove 9 and 4th index will remove 15.
How can I remove items from a_list with the indexes specified in a separate list?
new list = [j for i, j in enumerate(a_list) if i not in [0, 7, 9]].... another solution is instead of removing items, replace them with a temporary number or character eg 0... and then add an extra line...list(filter((0).__ne__, a_list))orlist(filter(lambda a: a != 2, a_list))