0

\n is not setting a new line for a string in my code. What is the problem?

class Account():
    
    def __init__(self, owner, balance = 0.0):
        self.owner = owner
        self. balance = balance
    
    def deposit(self, amount):
        self.balance += amount
        return (f'{amount} dollars has been deposited to your account. \nYou have {self.balance} dollars.') 
    
    def withdraw(self, amount):
        if amount > self.balance:
            print(f"Insufficient balance. You have {self.balance} dollars." )
        else:
            self.balance -= amount
            print(f"Left balance is: {self.balance}" )
    def __str__(self):
        return (f"Account's holder: {self.owner}\nBalance: {self.balance}")

When I try to:

acct1 = Account('Jose',100)
acct1.deposit(50)

The output is :

'50 dollars has been deposited to your account. \nYou have 150 dollars.'
ILS
  • 1,224
  • 1
  • 8
  • 14
frouLet
  • 13
  • 5

1 Answers1

1

You're just returning the value. Try:

acct1 = Account('Jose',100)
print(acct1.deposit(50))