u/Aternal99

I was able to create a simple banking program for my Python class. The only thing I am not able to figure out is how to perform more than one transaction. I can do one deposit and one withdrawal and display the account balance. How do I perform multiple transactions on the same account?

This is what I have:

class BankAccount:
    def __init__(self, deposit, withdraw, display, balance):
        self.deposit = deposit
        self.withdraw = withdraw
        self.display = display
        self.balance = balance
        self.balance = 0
    
    def deposit_amount(self):
        amount = float(input("Enter the amount you are depositing: "))
        self.balance += amount
        print("\n$", amount, " was deposited.")
        
    def withdraw_amount(self):
        wamount = float(input("Enter the amount you are withdrawing: "))
        if self.balance >= wamount: 
            self.balance -= wamount
            print("\n$", wamount, " has been withdrawn.")   
        else:
            print("Insufficient Funds available.")
        
    def display_amount(self):
        print("\nYour current balance is: $", self.balance)
        
    def check_balance(self):
        return self.balance

f __name__ == "__main__":
     baccount = BankAccount('deposit', 'withdraw', 'display', 'balance')
     baccount.deposit_amount()
     baccount.withdraw_amount()
     baccount.display_amount()
     baccount.check_balance()
reddit.com
u/Aternal99 — 7 days ago