I am trying to print several lists (equal length) as columns of an table.
I am reading data from a .txt file, and at the end of the code, I have 5 lists, which I wou
Assming that you have a lists of lists:
for L in list_of_lists:
print " ".join(L)
The str.join(iterable)
function, joins the components of an iterable by the string given.
Therefore, " ".join([1, 2, 3])
becomes "1 2 3".
In case I might have misunderstood the question and each list
is supposed to be a column:
for T in zip(list1, list2, list3, list4, list5):
print " ".join(T)
zip()
merges the given lists to one list of tuples:
>>> zip([1,2,3], [4,5,6], [7,8,9])
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
Cheers!