PRVS PRVS - 2 years ago 125
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:


Answer Source

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:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download