[SOLVED] Understanding local variable memory allocation: Could you please have a look at this code?
Why, when change_list() is called on L under the definition of g(), does Python store the index assignment in g()'s local variable L' s address, but create a change_list() local var for L? When you call a function inside the def of another function, on that other function's local variable, how does Python make a distinction between the local var of g() and that of the function nested in it, change_list()? *-->edited this sentence, being clumsy* In short why does L in L[0] = 4 get a different treatment than the L that follows in the next line? Is it that accessing the index assumes a previous assignment? Why doesn't it continue from there and alter the whole list again as dictated by the second assignment under change_list? https://code.sololearn.com/cUbtz18BfQS1/?ref=app