John Salerno wrote: > Duncan Booth wrote: > >> If you build a >> list of lines to join then you don't have to repeat '\n' on the end of >> each component line. > > How would that work? Wouldn't the last line in the list still need the > newlines?
>>> chunks = ["alpha", "beta", "gamma"] >>> "\n".join(chunks) 'alpha\nbeta\ngamma' You mean a '\n' after 'gamma'? >>> chunks.append("") >>> "\n".join(chunks) 'alpha\nbeta\ngamma\n' Peter -- http://mail.python.org/mailman/listinfo/python-list