Help with W05 List General Problem

Hi
I tried to solve the Week 5 problem with list. Somehow, i am unable to get the correct response.

Below is my snippet.
Can someone help me crack it!
def square_matrix_power(A,n):
C=[item[:] for item in A]
temp=[item [:] for item in A]
for num in range(int(n)-1):
for i in range(len(A)):
for j in range(len(A)):
for k in range(len(A)):
C[i][j] += A[i][k]*temp[k][j]
temp = [item[:] for item in C]
return C
num= input(‘Input value of n :’)
square_matrix_power(A,num)

Hi @krithika18.ece , welcome to the community. Could you please specify the response that you are getting and the corresponding input values given?

Hi
the input is
A=[
[1,1],
[1,0]
]
and the output is
Output=[[3, 2], [2, 1]]

I am trying to compute A power n

Hi @krithika18.ece, You seem to have wrongly initialised the matrix C. The matrix needs to be initialised to zero instead. Hope this helps!!