generate functionWed, 08 Feb 2023

Write a program that prints the maximum element in the area below the main diagonal of a square matrix.

def max_under_diagonal(matrix): max_el = None for i in range(len(matrix)): for j in range(len(matrix[i])): if i + j < len(matrix) - 1: if max_el is None or matrix[i][j] > max_el: max_el = matrix[i][j] return max_el print(max_under_diagonal([[2, 3, 1], [4, 6, 5], [7, 9, 8]]))

Questions about programming?Chat with your personal AI assistant