passing arguments from variables defined outside of function
I am a little bit confused here: when Kenneth passes the variable player as an argument into another function, does that function access that variable, even though it was assigned inside of another function? Are variable assignments within functions global?
Chris FreemanTreehouse Moderator 58,991 Points
Not sure if I understand the context correctly. If a variable, such as
player, is assigned inside some function it is local to that function. While inside that function, if a call to another function is made with
player as the argument, then the other function can access
player as needed. Neither of these two
player references would be considered global.
Python passes arguments "by object reference", it is not actually passing the object or its value between calls.
Post back if you need more help.