Why does it give me a list index outside the error range when I use nested for loops?

mnr = entry ()
spl = mnr.split ()
m = int (spl[0])
n = int (spl[1])
r = int (spl[2])
A = []
B = []
AB = []
total = 0

for i in rank (m):
inp = entry ()
spl = inp.split ()
A.append (spl)

for i in the range (n):
inp = entry ()
spl = inp.split ()
B.append (spl)

for i in rank (m):
for k in rank (r):
for j in rank (n):
print (j)
total + = int (A[i][j]) * int (B[j][k])
AB[i][k] = total
total = 0

for i in AB:
for j in i:
print (j, final = "")
Print()

This code is intended to multiply two matrices for a problem on snakify.org.

It is giving me a list index outside the error range for line 23 (for j in the range (n) :).

How can I get an error related to a list when I'm not using a list on that line?