How to pass a variable by reference?

In Python, variables are typically passed by value, which means that a copy of the variable is passed to the function, rather than the original variable itself. However, when I tried to pass a reference of my variable to the function, it is not working the way I assume that outside its value will change. For this purpose, I have developed a code that is below:

In the above code, I’m trying to achieve that my variable x value gets updated inside the function and when I print its value outside the function, the updated value will display. But, in the above code, I’m getting an old value.

Can someone explain that is it possible in Python to pass a variable by reference? If yes, share with me the code that helps to pass a variable by reference.