I am new in python, so i used to practice some. I tried;
>>> x = [1, 2, 3, 4]
>>> y = x
>>> for i in range(0, len(x)):
... y[i] = x[i]**2
...
>>> y
[1, 4, 9, 16]
>>> x
[1, 4, 9, 16]
My problem :
I can't understand why x
is changed,too.
I just expected y
like this : y = [1, 4, 9, 16]
(yes, it works in right way)
But, you see, x
is also changed : x = [1, 4, 9, 16]
(this makes me embarrassing)
How can i fix my mistake?