em bị lỗi list index out of range có anh chị nào biết cách sửa thì chỉ điểm giúp em với ạ
mã lỗi:
File "c:\Users\HoangAnh\Documents\main.py", line 31, in <module>
dichuyen(a,b)
File "c:\Users\HoangAnh\Documents\main.py", line 27, in dichuyen
if u>=0 and u<n and v>=0 and v<n and A([u][v])==0:
IndexError: list index out of range
X=[-2,-2,-1,-1,-1,1,1,2,2]
Y=[-1,1,-2,2,-2,2,-1,1]
A=[[],[]]
dem=0
print("nhap n")
n= int(input())
print("nhap vi tri ban dau x,y:")
a=int(input())
b=int(input())
def xuat():
for i in range(n):
for j in range(n):
print(A[[i],[j]])
def dichuyen(x,y):
global dem ,n
dem=dem +1
A[[x][y]]=dem
for i in range(8):
if dem== n * n :
print("cac buoc di chuyen la")
xuat()
exit()
u=x+X[i]
v=y+Y[i]
if u>=0 and u<n and v>=0 and v<n and A[u][v]==0:
dichuyen(u,v)
dem=dem-1
A[[x][y]]=0
dichuyen(a,b)