Python strings question (vertical stack)

J. Clifford Dyer jcd at sdf.lonestar.org
Tue Nov 20 15:08:55 EST 2007


On Tue, Nov 20, 2007 at 11:40:59AM -0800, Farshid Lashkari wrote regarding Re: Python strings question (vertical stack):
> 
> dmitrey wrote:
> > Hi all,
> > I have some strings, let it be string1, string2, string3.
> > 
> > So how could String=
> > """
> > string1
> > string2
> > string3
> > """
> > 
> > be obtained?
> > 
> > Thank you in advance, D.
> 
> If you just want the to add newlines between the strings then you can do 
> the following:
> 
> String = '\\n'.join([string1,string2,string3])
> 
> -Farshid
> -- 
> http://mail.python.org/mailman/listinfo/python-list

I think you mean '\n'.join([string1,string2,string3])

You actually do want the \ to do its thing in this case.

Cheers,
Cliff



More information about the Python-list mailing list