Finding the max product of a 2D array
First of all, if this function is not in a class you must remove the self parameter, there's no need of that. Then you should insert a check if the parameters are correct, that is the rows number and the columns number must be at least equals to maxLength: 

if len(matrix) &lt; maxLen and len(matrix[0]) &lt; maxLen:
        return -1 # return error code


In this cases, when you have to move across a matrix, I suggest you to use a sort of direction tuples, which are tuples of the form (1,0), (0,1), (1,1), (-1,0) etc..; so for each element of the matrix you add to the indexes of that element one of this tuples multiplied for a number. Maybe it's more complicate to speak about it than show it: 

def maxPathProduct(matrix, maxLen):
    if len(matrix) &lt; maxLen and len(matrix[0]) &lt; maxLen:
        return -1
    maxProduct = -1
    maxList = []
    directions = [(1, 0), (0, 1), (1, 1)] 
    for i in range(len(matrix)):
        for j in range(len(matrix[0])):
            for dir in directions:
                tempProduct = 1
                tempList = []
                inc = 0
                indexOutOfBound = False
                while len(tempList) &lt; maxLen and not indexOutOfBound:
                    row = i + dir[0] * inc
                    col = j + dir[1] * inc
                    if row &lt; len(matrix) and col &lt; len(matrix[0]):
                        tempProduct *= matrix[row][col]
                        tempList.append(matrix[row][col])
                        inc += 1
                    else:
                        indexOutOfBound = True
                if tempProduct &gt; maxProduct:
                    maxProduct = tempProduct
                    maxList = tempList
    return maxProduct, maxList


In this case you have only to move from left-to-right ((0,1)), up-to-down ((1,0)) and diagonally-up-to-down ((1,1)). With those direction tuples you can avoid that terrible long list of if-elif-else. I've tried this solution a bit, I'm not completely sure that it works, but I hope that you understand the trick.