I wanted to modify an array but keeping an original version of it so I coded:
a = ["a","b","c","d","e","f"]
b = a
a.append("g")
I expected:
a = ["a","b","c","d","e","f","g"]
b = ["a","b","c","d","e","f"]
But I retrieved:
a = ["a","b","c","d","e","f","g"]
b = ["a","b","c","d","e","f","g"]
It does not matter if I append a value to a
or b
, I get the same result.