I have complex number in the form of a string
x = 1+3j
Using the split()
method of strings , I want to break it into the real and imaginary parts.
What I tried :
I used the +
as a separator of the string and got the real and imaginary values.
Problem: The complex number can also be3-7j
, I that case , split()
fails as the string does not have a +
.
What a want is that the split()
should split the string when it encounters either +
or -