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)
1 Answer
+ 4
def __add__(self, other):
return self.j + other.j