def sub(M, m, n, x, y): import numpy as np M=np.array(M) print(M[x:x+m,y:y+n]) M = [ [3, 2, 1, 2], [5, 4, 3, 3], [7, 3, 6, 4] ] sub(M, 2, 2, 0, 1)