I would like to ask the formal parameter of the Python function, why sometimes "shallow copy" and sometimes "deep copy"?

I would like to ask why the formal parameter of the Python function can be changed sometimes and sometimes not? Forgive me for not knowing how to describe it, so I borrowed the concept of "deep and shallow copy".

def func(x,y,l):
    x = y+1
    l.append(0)
    
if "__main__" == __name__:
    x=10; y=10; l=[3,2,1]
    func (x,y,l)
    print (x,y, l)

I would like to ask: after running the function func, why the values of x and y do not change, but l change? Is there any way for
1 to let l remain the same as x and y and release it directly after running the function?
2 is there any way to change x and y like l? Return?

Thank you first!

Mar.07,2021

first of all, you need to understand two points: 1 assignment (=) is the application of the address; 2int is a mutable object, and list is a mutable object. Here we briefly talk about mutable and immutable. When the value of the immutable object changes, the referenced address changes ; the value of the mutable object changes, but the referenced address remains the same . The re-assignment of x and y will cause xjue y to point to other addresses, but l will always point to the same address. For a detailed introduction to mutability and immutability, link https://zhuanlan.zhihu.com/p/.

ask: "Why is it that the values of x and y have not changed, but l have changed?"
Xbox 10 is the same reference to "10". The x in the x and y functions is re-assigned, pointing to the address id (x) has changed, while l pointing to the address remains the same,

ask: "is there any way to make l remain the same as x and y and release directly after running the function?"
No, you can only delete this element from list

ask: "is there any way to make x and y change like l? Return? "
needs to reassign the value to x

. The following code is only for x

.
def func(x, y, l):
    x = y + 1
    l.append(0)
    return x, l
if "__main__" == __name__:
    x = 10;
    y = 10;
    l = [3, 2, 1]
    x, l = func(x, y, l)
    print (x, y, l)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eabf27-46b19.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eabf27-46b19.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?