I am writing a function that calculates complex number multiplication using python2.7. The funtion is:
def complexNumberMultiply(self, a, b):
"""
:type a: str
:type b: str
:rtype: str
"""
c,d = a.split('+')
e,f = b.split('+')
d = int(d[:-1])
f = int(f[:-1])
print c,d,e,f
return '%s+%si' % (c * e - d * f, c * f + d * e)
But when I run it, I get this error:
In complexNumberMultiply return '%s+%si' % (c * e - d * f, c * f + d * e)
TypeError: can't multiply sequence by non-int of type 'str'
My questions is, why my int(d[:-1]) didn't turn the string (e.g. -2) into an integer?