+ 2

I need help, please tell me what wrong in my code in task "Making a Deposit" in Python Core Course [SOLVED]

Please help me, I stuck in this task, in "Making a Deposit". This is my code: class BankAccount: def __init__(self, balance): self._balance = balance def __repr__(self): return "Account Balance: {}".format(self._balance) def deposit(self, amount): #your code goes here self.amount = amount total = self._balance + self.amount return total acc = BankAccount(0) acc.deposit(int(input())) print(acc)

21st Sep 2021, 1:29 AM
Andris Iswahyudi
6 Réponses
+ 3
I mean, what is the problem description. Can you copy-paste it here, or put a link from it.
21st Sep 2021, 8:01 AM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
+ 3
It says: "... and output the object" (not an integer value). So: def deposit(self, amount): self._balance += amount return self
21st Sep 2021, 8:26 AM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
+ 1
What does the problem want?
21st Sep 2021, 3:58 AM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
+ 1
Thank you very much, this is like a sunrise for me😊
21st Sep 2021, 8:40 AM
Andris Iswahyudi
0
The result not expected want
21st Sep 2021, 7:54 AM
Andris Iswahyudi
0
You are given a BankAccount class and need to add a deposit() method to it, which adds the given amount to the private balance property. The code should declare a BankAccount object with an initial balance of 0, take a number from user input, add it to the balance using the deposit() method, and output the object. Complete the required deposit() method so the code works as expected and produces the required output.
21st Sep 2021, 8:08 AM
Andris Iswahyudi