Is there an efficient way to solve the following problem:
lst = [1,2,3,4,5] indexes_to_remove = [0,2,4] #result lst = [2,4]
My solution
lst = [1,2,3,4,5] indexes_to_remove = [0,2,4] lst = [item for i, item in enumerate(lst) if i not in indexes_to_remove] print(lst)
Prints:
[2, 4]