I am not able to understand what is happening in the code below
#swaps list in index 1
L=[[1,2],[3,4]]
def swap(X):
beta=X[:]
beta[1][0],beta[1][1]=beta[1][1],beta[1][0]
return beta
def code(W):
alpha=W[:]
print swap(alpha)
return swap(alpha)
print code(L)
It gives an output
[[1, 2], [4, 3]]
[[1, 2], [3, 4]]
While i am expecting
[[1, 2], [4, 3]]
[[1, 2], [4, 3]]