In BASIC, a two-dimensional array of 10x10, in Python, 2x10. Of course will not work.
The whole cycle in Python is very easy to describe:
m=5 KTR = [ [0 if j<i+1 else 1 for j in range(1,m+1) ] for i in range(1,m) ]
Result:
[[0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]
For some reason, the boundaries of the array are indicated by 2*M , and the search goes only up to M - most likely it is insurance against going beyond the array: so those who write on BASIC like to write.
This, however, is easy to fix. We expand the boundaries to 2*M and at the same time shift the indices by 1, because in BASIC the first index of the array is 1, not 0:
KTR = [[None]*2*m]+[None]+[ [None]+[0 if j<i+1 else 1 for j in range(1,m+1) ]+[0]*m for i in range(1,m) ]+[ [None]+[0]*2*m for k in range(m+1) ]
Result:
[[None, None, None, None, None, None, None, None, None, None, None], [None, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0], [None, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [None, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
Now, just like in BASIC.
Well, a simple (but boring) translation as it is in Python from the original BASIC:
m = 5 KTR = [ [0]*(2*m+1) for k in range(2*m+1) ] for i in range(1,m): for j in range(i+1,m+1): KTR[i][j] = 1