+ 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)
6 Respostas
+ 3
I mean, what is the problem description. Can you copy-paste it here, or put a link from it.
+ 3
It says: "... and output the object" (not an integer value). So:
def deposit(self, amount):
self._balance += amount
return self
+ 1
What does the problem want?
+ 1
Thank you very much, this is like a sunrise for me😊
0
The result not expected want
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.