In my Python script for the line
result = sp.solve(eqn)
I get the following output in the format similar to
result = 0.0100503358535014*I
I gather this means the solution is a complex number. So in this case it could also be seen as result = 0.01j.
I want to add formatting to my code to change result = 0.0100503358535014*I to something more like result = 0.01j. However I am finding issues trying to do this as I was trying to use isinstance to check if result was complex
if isinstance(result, complex):
print "Result is complex!"
... my code here...
However this loop is never entered (i.e 0.0100503358535014*I isn't classified as complex here).
What way should I write an if statement to check if result is given in the manner xxxxxxx*I correctly?
Ihere? Some special constant? If you're not working withcomplex, what are you working with?Iis an actual symbol (it's probably a SymPy library), and not an indication of a complex number.type(result)?type(result) = <class 'sympy.core.mul.Mul'>if isinstance(result, sympy.core.mul.Mul):