Python SyntaxError :'return' outside function - Stack Overflow
stackoverflow.com › questions › 13068043Oct 25, 2012 · File "temp.py", line 56 return result SyntaxError: 'return' outside function. Where was I wrong? class Complex (object): def __init__ (self, realPart, imagPart): self.realPart = realPart self.imagPart = imagPart def __str__ (self): if type (self.realPart) == int and type (self.imagPart) == int: if self.imagPart >=0: return '%d+%di'% (self.realPart, self.imagPart) elif self.imagPart <0: return '%d%di'% (self.realPart, self.imagPart) else: if self.imagPart >=0: return '%f+%fi'% (self.