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_elem(mat): i = 0 max_elem = -10000 while i < len(mat): j = 0 while j < len(mat[i]): if j > i and mat[i][j] > max_elem: max_elem = mat[i][j] j += 1 i += 1 return max_elem max_elem([[1, 2, 3],[4, 5, 6],[7, 8, 9]])

Questions about programming?Chat with your personal AI assistant