I am trying to swap local variables within a function to rotate a 2 by 2 matrix by 90 degrees.
def twobytwo(m):
last = len(m)-1
for i in range(0, last):
swap(m[i][i], m[i][last])
swap(m[i][i], m[last][last])
swap(m[i][i], m[last][i])
return m
def swap(i, j):
temp = i
i = j
j = temp
print(twobytwo([[0, 1], [2, 3]]))
Currently, I am returned the original matrix but I want to see
[[2,0],[3,1]]