On Dec 30, 11:31 am, wx1...@gmail.com wrote: > I have a list and would like to parse the list appending each list > item to the end of a variable on a new line. > > for instance > > mylist = ['something\n', 'another something\n', 'something again\n'] > > then parse mylist to make it appear in my variable in this format: > > myvar = """ > something > another something > something again""" > > how would i go about setting a variable like this?
I think you want to concatenate the three elements in your list and then assign the resulting string to myvar. Strings that are defined with tripple quotes still get the newline character as though they were defined with double or single quotes and \n in them. >>> conc = lambda x,y: x[:] + y # concatenate 2 lists without side effects >>> mylist = ['something\n', 'another something\n', 'something again\n'] >>> myvar = reduce(conc, mylist) >>> print myvar something another something something again Hope this helps michael -- http://mail.python.org/mailman/listinfo/python-list