I would like to write one function which as argument takes one variable, say x
.
Now I would like to use this function in such a way that I can pass any global variable and its value will change after execution of this function. So I would like to get sth like that:
y = 2
def f(x):
global x
x = 2 * x
In the above code of course will not work because I have to pass global y
instead of `global x' but if I want to use the same funtion for many variables then this is problematic. What can I do?