Say I have two lists: a=[1,2,3] b=[4,5,6] I want to write them into a text file such that I obtain a two column text file:
You can write two lists into a text file that contains two columns.
a=[1,2,3] b=[4,5,6] c = [a, b] with open("list1.txt", "w") as file: for x in zip(*c): file.write("{0}\t{1}\n".format(*x))
Output in the text file:
1 4 2 5 3 6