Python question

Hi-

I just finished the Bank Teller off-platform exercise in the Python for Finance course. My code works well, but I’m wondering if there is a more efficient way to organize it.

Within all of the functions are two parameters that refer to variables, checking_balance and savings_balance, that update the amount within each account as money is deposited, withdrawn, and transferred between the two accounts.

Every time any of the functions were called, I had to include these two variables at the end of the parameters. My question is this– is there a way to set these as default within the function definition so that I don’t have to type them out every time I want to call the function?

I remember learning how to set default values for functions, but it didn’t work for my code so now I’m wondering if that only works for numbers and not variables.

Thanks!

Hello! It’s hard to tell exactly what the problem is without seeing exactly what you’ve tried - you mention that setting the default values didn’t work, didn’t work how, exactly? Did you get an error message/traceback?

Perhaps posting a code snippet or two showing the structure of what you’re writing would make it clearer!

Default values for parameters of a function must be immutable … like a string or integer or float, but not a variable
in Python.
There are ways for functions to access or change variables declared outside the function (if the variable is in global scope - meaning outside everything).
(The global keyword works in some situations.)

x = 3 print(x) def doubleX(): global x x = x * 2 doubleX() print("doubleX( )") print(x)