Question: I wrote such a code, but when I run it, the last two columns are missing. I think the problem is in the n matrix

I wrote such a code, but when I run it, the last two columns are missing. I think the problem is in the n matrix length, but couldnt solve the problem def task03(matrix): n = len(matrix) substituted = 0 P = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): if matrix[i][j] != 0: P[i][j] = matrix[i][j] else: row_sum = sum(matrix[i][j + 1:]) col_sum = sum(matrix[k][j] for k in range(i)) P[i][j] = row_sum + col_sum substituted += row_sum + col_sum if n <= 20: print(' '.join(' '.join(str(P[i][j]) for j in range(n)) for i in range(n))) else: right_bottom_submatrix = [row[-20:] for row in P[-20:]] print(' '.join(' '.join(str(right_bottom_submatrix[i][j]) for j in range(20)) for i in range(20))) print(substituted)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!