I am currently having problems with the Bank Teller project for python.
the step are:
6. Call deposit function and make a savings deposit
On the next line, call the
make_deposit() function with these arguments;
savings_balance . Assign the function call to the matching
savings_balance variables that are also being returned by the function. That is how the new balances are being updated.
7. Print savings balance call after making a savings deposit
Now that a deposit has been made to the savings account, print your savings balance. Call the
check_balance() function with these arguments;
savings_balance within a print function. Your new savings balance should print.
The problem i’m having is when I perform step 6. The amount 10 is assigned to the Checking account variable when it should be the savings account. and when I change the account_type parameter to checking it goes to the savings account.
this is my code for the project:
checking_balance = 0
savings_balance = 0
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 "Please Input Checking or Savings Account. Thank You!" balance_statement = "Your " + account_type + " balance is " + str(balance) return balance_statement
def make_deposit(account_type, amount, checking_balance, savings_balance):
deposit_status = " "
if amount > 0:
if account_type == “Checking”:
checking_balance += amount
deposit_status = “Successful!”
elif account_type == "Savings": savings_balance += amount deposit_status = "Successful!" else: return """Must Choose "Checking" or "Savings" account to successfully complete deposit.""" else: return "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
savings_balance, checking_balance = make_deposit(“Savings”,10,savings_balance, checking_balance)
check_balance(“Savings”, checking_balance, savings_balance)