3zzy 3zzy - 4 months ago 10
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?

Thanks

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