For loop result

Hi,I wrote a code for solving a finite element problem.for loop fourth times generates k(a matrix) .i want to sum the k together,but i can’t.what change i have to make in for loop?

import numpy as np
#Coordinate and Thickness
x,y,t=[1,1,2,2],[0,1,1,0],1
# Material Property,Elasticitycondition 1 is Plane Strain/Elasticitycondition 0 is Plane Stress 
E,P,Elasticitycondition=210,0.25,0 
#Define coordinate matrix and gaussian points(1 points),counter clockwise direction
c=np.vstack([x,y])
ke,te=[-0.577,-0.577,0.577,0.577],[-0.577,0.577,0.577,-0.577]
# D Matrix Calculation
cof1=E/((1+P)*(1-2*P))
cof2=E/(1-(P**2))
K1=[[1-P,P,0],[P,P,0],[0,0,(1-2*P)/2]]
K2=[[1,P,0],[P,1,0],[0,0,(1-P)/2]]
D=np.zeros((3,3))
if Elasticitycondition==1:
    D+=K1
    D*=cof1
elif Elasticitycondition==0:
    D+=K2
    D*=cof2  
#Calculation Strain and stiffness matrix
for i in range(len(ke)):
        k=np.zeros((8,8))
        df=np.zeros((4,2))
        df+=[[-1+te[i],-1+ke[i]]
            ,[1-te[i],-1-ke[i]]
            ,[1+te[i],1+ke[i]]
            ,[-1-te[i],1-ke[i]]]
        df*=0.25
        j=c@df
        df2=df@np.linalg.inv(j)
        b=[[df2[0,0],0,df2[1,0],0,df2[2,0],0,df2[3,0],0]
          ,[0,df2[0,1],0,df2[1,1],0,df2[2,1],0,df2[3,1]]
          ,[df2[0,1],df2[0,0],df2[1,1],df2[1,0],df2[2,1],df2[2,0],df2[3,1],df2[3,0]]]
        k=[t*np.linalg.det(j)]*np.transpose(b)@D@b
        print(k)

Is this associated with a Codecademy lesson? Numpy has functions for adding together the elements of a matrix or for adding two matrices together and your code already contains usages of operators would be appropriate for summation throughout your loops.

no,it’s not.i used np.add() before but didn’t worked.what operators is your mean?