close, filter and unzip again:
ids, other = zip(*((id, other) for id, other in zip(ids, other) if id not in del_ids))
The zip() parameter calls each id with the corresponding other element, the generator expression filters any pair where id is specified in del_ids , and zip(*..) then teases the remaining ones again, add the pairs to separate lists.
Demo:
>>> del_ids = [2, 4] >>> ids = [3, 2, 4, 1] >>> other = ['a', 'b', 'c', 'd'] >>> zip(*((id, other) for id, other in zip(ids, other) if id not in del_ids)) [(3, 1), ('a', 'd')]
source share