+ 1

Instance of bankaccount has no depo as memeber

Please someone help me to find out what i am missing here, try to add an input to the existing bankaccount, the error of missing depo as member always show up: class BankAccount: def __init__(self, balance): self._balance = balance def __repr__(self): return "Account Balance: {}".format(self._balance) #your code goes here def deposit(self, depo): depo = self.depo self._balance += self.depo acc = BankAccount(0) acc.deposit(int(input())) print(acc._BankAccount__repr())

9th Sep 2020, 4:37 PM
WENy Z
WENy Z - avatar
1 ответ
+ 2
There is no self.depo intialized when you create an instance "acc" . self refers to the object itself ,it is simply depo , if you want to use self.depo you can put it inside init method with self.depo assigned any value and then assign new value to it in deposit method like self.depo=depo #when calling deposit method or it is just a simple value that you are passing as an argument and accessing it as a parameter depo=depo
9th Sep 2020, 4:45 PM
Abhay
Abhay - avatar