n = 3
matrix = [[1, 2, 3, 4], [1, 2, 3, 1], [2, 3, 1, 3], [2, 1, 4, 2]]
col_counter = [1, 1, 1, 1]
for row in range(0, len(matrix)):
    row_counter = 1
for col in range(0, len(matrix[row])):
    current_element = matrix[row][col]
if col > 0:
    previous_element = matrix[row][col - 1]
if current_element == previous_element:
    row_counter = row_counter + 1
if row_counter == n:
    print(n, 'in a row at:', row, col - n + 1)
else:
    row_counter = 1
if row > 0:
    previous_element = matrix[row - 1][col]
if current_element == previous_element:
    col_counter[col] = col_counter[col] + 1
if col_counter[col] == n:
    print(n, 'in a column at:', row - n + 1, col)
else:
    col_counter[col] = 1
better algorithm for checking 5 in a row/col in a matrix