I have a array as [2, 3, 1, 3, 1]
I want to define a 2 dimensional array of all 0s according to [2, 3, 1, 3, 1]
it will be something like
[ [0,0], [0,0,0], [0], [0,0,0], [0] ]
how to do it without hardcoding?
you could do something like this :
[[0 for x in range(y)] for y in [2,3,1,3,1]]
[ [0][0], [0][0][0], [0], [0][0][0], [0] ] I was thinking that meant : [[[0], [0]], [[0], [0], [0]], [[0]], [[0], [0], [0]], [[0]]]. I made the changes thanks