If you want to delete multiple specified positions (indexes), you cannot use pop or del. (Please make it usable ...)
l = ['0', '1', '2', '3', '4']
del l[0,1,3]
# TypeError: list indices must be integers or slices, not tuple
l.pop(0,1,3)
# TypeError: pop() takes at most 1 argument (3 given)
Instead of these, there is a list comprehension notation as a simple way to describe.
l = [x for i, x in enumerate(l) if i not in [0,1,3] ]
print(l)
# ['2', '4']
Recommended Posts