I want to change the position of two lists inside a list. Like this:
A = [[2,3,4], [5,-3,6]]
swap(A[0], A[1])
print(A)
#[[5,-3,6],[2,3,4]]
This does not work (Why?):
def swap(row1,row2):
temp = row2
row2 = row1
row1 = temp
While this works (Why?):
def swap(row1,row2):
for i in range(0,len(row2)):
temp = row2[i]
row2[i] = row1[i]
row1[i] = temp