Feb-28-2018, 04:35 PM
Hi, I need to find the appropriate list operations.
example:
x = [1, 2, 3]
y = x
y[1] += 2
print(x)
>> [1, 4, 3]
How can I have y become the same list as x without x being influenced y?
I want the example to return [1, 2, 3] and let y be defined by x and be able to do any operation I want on y.
If i am not clear let me know thx.
example:
x = [1, 2, 3]
y = x
y[1] += 2
print(x)
>> [1, 4, 3]
How can I have y become the same list as x without x being influenced y?
I want the example to return [1, 2, 3] and let y be defined by x and be able to do any operation I want on y.
If i am not clear let me know thx.