Hi guys.
One quick question, as I noticed in this code at the last line I’ll have to assign the two variables in the order of “savings” comes first and then “checking”.
If I went the other way around, the variables wouldn’t get updated.
Does this have something to do with sequences of the boolean statement(line 4) or the return results(line 19)?
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 savings_balance, checking_balance
savings_balance, checking_balance = make_deposit("savings", 10, checking_balance, savings_balance)