def func(t):
t = 5
print('inside function', t)
print('inside function address = ', id(hex(t)))
x = 3
func(x)
print('outside function',x)
print('outside function address = ', id(hex(x)))
This Prints
inside function 5
inside function address = 31255648
outside function 3
outside function address = 31255648
My understanding was a variable referenced in a function without assignment will use a variable outside of its scope. But if the function has an assignment, then it will create a new variable in a new space in memory and assign it there.
Why does the function id find the original address of the argument instead of the address of the newly created variable?