Why I am getting this error (TypeError: can only concatenate str (not "complex") to str? I am not doing any kind of concatenation in my code. I am confused, please help me.
print("%d" % 5+8j)
Why I am getting this error (TypeError: can only concatenate str (not "complex") to str? I am not doing any kind of concatenation in my code. I am confused, please help me.
print("%d" % 5+8j)
You need parenthesis
print("%s" % (5+8j))
Otherwise, it's understood as
print(("%s" % 5)+8j)
Incidentally, there is no point in using %d instead of %s, as it's just less general.