PRVS PRVS - 7 months ago 10
Python Question

how to print array as a table in python

I'm trying to print an array like:

Table = [(0,0,0),(0,0,1),(0,1,0)]
.

Therefore, I want to print this array as a table like:

0 0 0
0 0 1
0 1 0


How can I make this?

I tried a simple
print Table
but this prints the array like this:

[(0,0,0),(0,0,1),(0,1,0)]

Answer

Have you tried a basic for loop?

for line in Table:
    print ' '.join(map(str, line))

It's prettier in Python 3:

for line in Table:
    print(*line)