• Can someone help me?

Question related to mission Golden Pyramid

 

def countgold(pyramid): """ Return max possible sum in a path from top to bottom """ lst = [] lstt = [] finallst = [] ffinallst = [] M = int() for i in range(len(pyramid)) :

    for j in range(len(pyramid[i])) :

        if len(pyramid[i]) == 1 :

            lst.append([pyramid[i][j]])
            break

        elif len(pyramid[i]) == 2 :

            lst.append([int(lst[0][0]) + int(pyramid[i][k]) for k in range(2)])
            break

        elif len(pyramid[i]) > 2 :

            for l in range(len(lst[-1])) :

                if j == 0 :

                    lst_t.append(int(pyramid[i][0]) + int(lst[-1][0]))
                    break

                elif j == (len(pyramid[i])-1) :
                    lst_t.append(int(pyramid[i][-1]) + int(lst[-1][-1]))
                    lst.append(lst_t)
                    lst_t = []
                    break

                elif 0 < j < (len(pyramid[i])-1) :
                    while (j-1)*(i-2) <= l <= (j-1)*(i-2)+(i-1) :
                        lst_t.append((int(pyramid[i][j])+int(lst[-1][l])))
                        break

for i in lst[-1] :
    ffinal_lst.append(i)
M = (max(ffinal_lst))
return M

I can't figure out what's wrong in my code. Can someone help me?