I've been trying to parse a string and to get rid of parts of the string using the remove() function. In order to find the part which I wanted to remove I used an OR operator. However, it does not produce the outcome I expected. Can you help me?
My code looks like this:
import numpy as np
x = '-1,0;1,0;0,-1;0,+1'
x = x.split(';')
for i in x:
if ('+' in i) or ('-' in i):
x.remove(i)
else:
continue
x = ';'.join(x)
print(x)
The outcome I expect is:
[1,0]
Instead the outcome is:
[1,0;0,+1]