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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -