Printing lists onto tables in python -


if had 3 lists such as

a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] 

and wanted print this

1  4  7 2  5  8 3  6  9 

how that?

the hard part of transposing array. that's easy, zip:

a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] t = zip(a, b, c) 

now print out:

print('\n'.join('  '.join(map(str, row)) row in t)) 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -