Analyse Financial Data with Python Skill Path - Bank Teller Project

Hi all,

Started on Codecademy two weeks ago to stay productive during confinement. First-time coder so looking for any feedback on my codes, and open to any tips, suggestions for encouragement for coding.

This is the link to the Bank Teller project:
https://www.codecademy.com/paths/finance-python/tracks/introduction-to-python-for-finance/modules/introduction-to-jupyter-notebooks/informationals/bank-teller

I’ve followed the instructions as best as possible, and then cross-referenced the solutions. All codes work as required when running codes in order in Jupyter Notebook, but once changing the order, it gets a little whacky with retaining the account balances. I’m not sure if this is because of my codes or just a characteristic of Jupyter Notebook.

Anyway, my functions are below:

Initial balances:

checking_balance = 0
savings_balance = 0

Display available balance function:

def check_balance(account_type, checking_balance, savings_balance):
    if account_type == "savings":
        balance = savings_balance
    elif account_type == "checking":
        balance = checking_balance
    else:
        return 'Unsuccessful, please enter \"checking\" or \"savings\"'
    balance_statement = "Your " + account_type + " balance is " + str(balance) + '.'
    return balance_statement

Making a deposit function:

def make_deposit(account_type, amount, checking_balance, savings_balance):
    deposit_status = ""
    if amount > 0:
        if account_type == "savings":
            savings_balance += amount
            deposit_status = "successful."
        elif account_type == "checking":
            checking_balance += amount
            deposit_status = "successful."
        else:
            deposit_status = 'unsuccessful, please enter \"checking\" or \"savings\"' 
    else:
        deposit_status = "unsuccessful, please enter an amount greater than 0."
    deposit_statement = "Deposit of $" + str(amount) + " to your " + account_type + " account was " + deposit_status
    print(deposit_statement)
    return checking_balance, savings_balance

Making a withdrawal function:

def make_withdrawal(account_type, amount, checking_balance, savings_balance):
    withdrawal_status = ""
    fail = "unsuccessful, please enter amount less than balance"
    if account_type == "savings":
        if amount > savings_balance:
            withdrawal_status = fail
        else:
            savings_balance -= amount
            withdrawal_status = "successful"
    elif account_type == "checking":
        if amount > checking_balance:
            withdrawal_status = fail
        else:
            checking_balance -= amount
            withdrawal_status = "successful"
    else:
        withdrawal_status = "unsuccessful, please enter \"checking\" or \"savings\""
    withdrawal_statement = "Withdrawal of $" + str(amount) + " from your " + account_type + " account was " + withdrawal_status
    print(withdrawal_statement)
    return checking_balance, savings_balance

Transferring between accounts Function:

def acc_transfer(acc_from, acc_to, amount, checking_balance, savings_balance):
    transaction_status = ""
    trans_error = "unsuccessful, please enter amount less than $"
    if acc_from == "savings" and acc_to == "checking":
        if amount <= savings_balance:
            savings_balance -= amount
            checking_balance += amount
            transaction_status = "successful"
        else:
            transaction_status = trans_error + str(savings_balance)
    elif acc_from == "checking" and acc_to == "savings":
        if amount <= checking_balance:
            checking_balance -= amount
            savings_balance += amount
            transaction_status = "successful"
        else:
            transaction_status = trans_error + str(checking_balance)
    else:
        transaction_status = "unsuccessful, please enter \"checking\" or \"savings\""
    transaction_statement = "Transfer of $" + str(amount) + " from your " + acc_from + " account to your " + acc_to + " account was " + transaction_status
    print(transaction_statement)
    return checking_balance, savings_balance

Voilà, looking forward to hearing your thoughts! Thanks very much!

Looks good dude! Heres My solution its very similar!

:facepunch:t5: :facepunch:t5: