3zzy 3zzy - 1 year ago 70
Python Question

Export list as .txt (Python)

My Python module has a list that contains all the data I want to save as a .txt file somewhere. The list contains several tuples like so:

list = [ ('one', 'two', 'three'), ('four', 'five', 'six')]

How do I print the list so each tuple item is separated by a tab and each tuple is separated by a newline?


Answer Source
print '\n'.join('\t'.join(x) for x in L)