How can I pass an integer by reference in Python?
I want to modify the value of a variable that I am passing to the function. I have read that everything in Python i
Not exactly passing a value directly, but using it as if it was passed.
x = 7 def my_method(): nonlocal x x += 1 my_method() print(x) # 8
Caveats:
nonlocal
global