So I will have two lists like this:
list1 = ['p', '-x', 'q123', '-q3']
list2 = ['p56', '-p', '-q123', 'xr']
So lets say if
CASE 1: an item from list1 == 'p' I need to check if '-p' is in list2 or,
CASE 2: an item from list1== '-p' I need to check if 'p' is on list2.
And then delete the element from list1 if any of these cases are triggered, so that I'm only left with elements that only appear in its negative form or only appear in its positive form. Right now I am able to do the CASE 1, but I'm not sure how to do CASE 2.
list1 = ['p', '-x', 'q123', '-q3']
list2 = ['p56', '-p', '-q123', 'xr']
new_list1 = list1.copy()
for y in list1:
for x in list2:
if x == '-'+y:
new_list1.remove(y)
For these two lists I would be left with only when I handle both cases
new_list1 = ['-q3']
Right now I'm getting this:
new_list1 = ['-x', '-q3']