If I have the following list of elements:
list = ['one', 'two', 'three', 'four']
and I have another list that contains the indexes I need to delete from the list above:
to_delete = [0,2]
How can I delete those elements from list
using to_delete
? Using a for
loop doesn't work since, obviously, when you delete one element from a list the index of each remaining element changes.
What can I do?