How do you write a function that returns the maximum element among all the numbers that are in even columns of matrix1 i.e the maximum element among all elements in 0th, 2th, 4th etc. column. Precondition: matrix1 is a matrix filled with numbers with at least 1 row and 1 column.
The expected resulted is as follows:
for j in range(ncols):
for i in range(nrows):
if i==0 or i%2 == 0:
This is pretty straightforward, I don't think it requires much explanation. The difficulty might be that we are used to iterating over lines then over columns, but here it is the other way round.
max = matrix for j in range(len(matrix)//2) : for i in range(len(matrix)) : if matrix[i][2*j] > max : max = matrix[i][2*j]