Converting a list to a string [duplicate]

Try str.join:

file2.write(' '.join(buffer))

Documentation says:

Return a string which is the concatenation of the strings in the iterable iterable. The separator between elements is the string providing this method.

Leave a Comment