I have two lists, and I'd like to subtract one from the other.
I have seen people using sets, but my lists contain duplicates, so I believe this is not an option for me.
int_list = [(1,1), (-1, 210), (-1, 210)]
new_list = [(-1, 210)]
final_list = [item for item in int_list if item not in new_list]
I get final_list = [(1,1)]
, but I would like to keep the second copy of (-1,210)
in the final list. I understand why this is happening, but I do not know another way to subtract the lists. I guess I can return the final list as it is, then append any elements from int_list which appear more than once, and which also appear in the new_list, but I feel like there should be an easier way.
any help appreciated