1
I need to modify a variable within a definition without globalizing the variable because then I can use the same definition with different variables.
I’ve tried the following code:
>>> n = 0
>>> def f(mmm):
mmm = 1
return mmm
>>> f(n)
>>> 1
>>> print(n)
>>> 0
Even after executing the setting, the variable n continues with the value of before, which I can do?
I think it is best that you assign the return of function f to variable n. That is n = f(n)
– Washington Luis