0

Python - Why doesn't this add class attributes?

Result should be 12: class J(str): def __init__(self,j): self.j=j ''' def __add__(self,other): self.j+other.j ''' def __add__(first,second): first.j+second.j x = J(5) y = J(7) print(x+y)

10/4/2019 11:55:23 AM

Paolo De Nictolis

1 Answer

New Answer

+4

def __add__(self, other): return self.j + other.j