Beginner here, I am trying to find a way to be able to define the "deposit" variable to result in different outputs based on the previous line of the output. For example, if the previous output of the code is "Sorry, minimum balance must be maintained. Account is frozen." I want any future deposits to have no impact on the balance, and to print "Sorry, account frozen." I have attached below the code I have so far. Thank you very much!
def withdraw(self, amount):
self.balance -= amount
if self.balance < self.min_balance:
print("Sorry, minimum balance must be maintained. Account is frozen")
self.balance += amount
return self.balance
def deposit(self, amount):
self.balance += amount
if self.balance - amount < self.min_balance and self.balance - amount != 0:
print("Sorry, account frozen.")
self.balance -= amount
return self.balance + amount
I expect the output to read: Account: FR646 Paul Depositing 500 Withdrawing 180 Withdrawing 180 Sorry, minimum balance must be maintained. Account is frozen Depositing 500 Sorry, account frozen. Balance: 320
Whereas, what I currently see is: Account: FR646 Paul Depositing 500 Withdrawing 180 Withdrawing 180 Sorry, minimum balance must be maintained. Account is frozen Depositing 500 Balance: 820
Aucun commentaire:
Enregistrer un commentaire