I have an array of n by n and use this part of code to display 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 would like to present 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 am I doing wrong?