I write the following code to create an array like [[1,2,3],[2,2,3],[3,2,3]]
,
def f(X):
X[0]=X[0]+1
return X
L=[]
X=[1,2,3]
for i in range(0,3):
L=L+[X]
X=f(X)
print(L)
But it is printing [[4, 2, 3], [4, 2, 3], [4, 2, 3]]
. Why it is happening and how to solve this using the function 'f'?
Thanks