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)

4th Oct 2019, 11:55 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
1 Answer
+ 4
def __add__(self, other): return self.j + other.j
4th Oct 2019, 1:52 PM
HonFu
HonFu - avatar