-2
I have a matrix of n by n and use this part of the code to present it:
for i in range(len(data)):
for j in range(len(data[0])):
print ((data[i][j]))
Being data
the matrix. But the output looks like this:
5
4
1
10
2
3
0
2
1
...
The values of data
are coming from here
data = [ [-1 for i in range(vertice)] for j in range(vertice)]
for i in range(vertice):
for j in range(vertice):
if data[i][j] < 0:
data[i][j] = random.randint(0, vertice)
data[j][i] = random.randint(0, vertice)
if i == j:
data[i][i] = 0
return data
I’d like to present it this way:
5 4 1 10 2
3 0 2 1 7
3 0 2 1 7
3 0 2 1 7
I’ve tried a thousand and one ways, but I’m not getting there. What I’m doing wrong?
And what values do you have in
data
?– Maniero
attribute Random values. It always shows, so I think it is this part of the code the error
– Walt057
And how do we know what’s wrong? For me it’s all right given past information. There’s random data being shown right.
– Maniero
it is the print that is wrong, but I put what you want
– Walt057
And how the print output should be?
– Woss
Yes, it should be said. Sry.
– Walt057
in the form of a matrix, I identify at least
– Walt057