What I'm trying to accomplish here is to generate a matrix of size n x n. Whatever the matrix is, I have to fill in the number 1
from the top-left corner to the bottom-right corner and 0
everywhere else.
def identity(m):
new_identity = []
old_identity = m
for i in range(len(old_identity)):
new_identity.append(old_list[1])
return new_identity
For example, if the matrix was 3 then the expected result would be:
[[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Or to make it easier to visualize:
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
ones = [[0]*i + [1] + [0]*(n-i-1) for i in range(n) ]