0
Why output "TypeError"
# My code as bellow: class Scores(): def __index__(self,math,english): self.math=math self.english=english def __add__(self, other): return Scores(self.math+other.math , self.english+other.english) joe=Scores(70,85) vivi=Scores(99,77) result=joe+vivi print(result.math) # Output: Traceback (most recent call last): File "/Users/linjoe/PycharmProjects/Joe's pratice/Boolean.py", line 9, in <module> joe=Scores(70,85) TypeError: Scores() takes no arguments
1 Odpowiedź
+ 2
You need to use 'init' instead of 'index'.