Menu

#Zeros

2 posts

Feed·
2 of 2 posts
0Read More

Faced an issue while making a matrix using [0]*n

Reddit r/learnpython·u/Indra_Kamikaze·6 months ago
#h0WGqXDh
#matrix#list#code#know#zeros

def get_matrix(n): rows, columns = n,n matrix = [[0]*n]*n for i in range(n): matrix[i][i] = 1 return matrix This was my code. I know that we can make a [0] list with n zeros by doing [0]*n.…

15s