I am a beginner in Python. I am having difficulty creating multidimensional array or list.
I want to do two things:
a) Create a list, b) Intialize the list
For example, if D is list then:
The total matrix is till D[8] [7] but I need to initialize only below values to 0
D[0][0] = 0
D[0][1] = 0
D[0][2] = 0
D[0][3] = 0
D[0][4] = 0
D[1][0] = 0
D[2][0] = 0
D[3][0] = 0
D[4][0] = 0
D[5][0] = 0
I tried following but its not working:
import numpy
Matrix = numpy.zeros((len(A) + 1, len(B) + 1))
for i in range(len(B) + 1):
Matrix[0][i] = i
for i in range(len(A) + 1):
Matrix[i][0] = i
But it gives output something like below which I don't want:
[[0. 1. 2. 3. 4. 5. 6. 7. 8.]
[1. 0. 0. 0. 0. 0. 0. 0. 0.]
[2. 0. 0. 0. 0. 0. 0. 0. 0.]
[3. 0. 0. 0. 0. 0. 0. 0. 0.]
[4. 0. 0. 0. 0. 0. 0. 0. 0.]
[5. 0. 0. 0. 0. 0. 0. 0. 0.]
[6. 0. 0. 0. 0. 0. 0. 0. 0.]
[7. 0. 0. 0. 0. 0. 0. 0. 0.]]