0
Operator Overloading : Code Coach
Help me with this problem. Couldn't figure out. https://code.sololearn.com/c4AYgEpRyWP9/?ref=app
3 odpowiedzi
+ 1
Line 4:
- Indentation error, should be at the same indent level with __init__()
- Method name should be __add__() with double underscores
Line 5:
- Empty line should be removed
Line 6:
- Line should be properly indented as body of __add__() method
def __init__(self, balance):
self.balance = balance
def __add__(self , other):
return BankAccount(self.balance + other.balance)
+ 1
Thanks ❤❤ .
0
These are called 'dunder' methods.
dunder as in Double UNDERscore.
for operator + use '__add__' method like this
https://code.sololearn.com/cNGAC4b3V9xU/?ref=app