Square Matrix Power Solution without hard coding?

can someone please verify whether the following approach to square matrix power is correct or not
without hard coding it for 2 * 2 matrix

def matrix_power(A,n):
    r = len(A)
    B = []
    row = []
    if (n == 1):
        return A    
    for m in range(r):
        a = [i for i in A[m]]
        for i in range(r):
            b = [A[k][i] for k in range(r)]
            number = (element(a,b))
            row.append(number)
        B.append(row)
        row = []        
    for l in range(3,n+1):
        for m in range(r):
            a = [i for i in B[m]]            
            for i in range(r):
                b = [A[k][i] for k in range(r)]                
                number = (element(a,b))                
                row.append(number)
            B[m] = [i for i in row]
            row = []          
    return B
def element(a,b):
    l = len(a)
    result = 0
    for i in range(l):
        result = result + a[i] * b[i]
    return result