'Issue understanding modification of variable in jupyter notebook
I'm quite new to jupyter and just can't figure out how this work :
With these 3 blocks of code, a multiple execution of the 3rd one make n incremental, i.e. [1,2], then [1,3], [1,4], etc
n = [1,2]
--
def fonction(x):
y=x
y[1]=x[1]+1
return y
--
res = fonction(n)
print(res)
This is the minimal example i can provide. I don't understand why the variable n is modified though it's only the argument in the 3rd block (and the 2nd block isn't modifying the argument of the function !)
Thanks a lot for your patience explaining 101 jupyter to this old engineer, sincerely
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
