iterating over last i . e ( n - 1 ) th row and connecting Node .
elif i == n - 1 and j <= m and j >= 1 : NEW_LINE INDENT if j == m : j = j - 1 NEW_LINE j = j - 1 NEW_LINE temp . prev = Node ( grid [ i ] [ j ] ) NEW_LINE temp = temp . prev NEW_LINE DEDENT