简体   繁体   中英

How to print 2d lists in python like a C table

i have a 2 lists and i want to make a 2d list but i want to be printed like a 2d table (like in C) and not in one row! My code is like:

c = []
for i in range(5):
    for j in range(5):
        c.append(a[i]-a[j])
print c

this is printed in a row

Assuming Python 2 based on your code sample:

c = []
for i in range(5):
    for j in range(5):
        c.append(a[i] - a[j])
        print c[-1],
    print

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM