concat next line with previous

Simon Brunning simon at brunningonline.net
Tue Sep 26 06:27:44 EDT 2006


On 26 Sep 2006 03:16:25 -0700, s99999999s2003 at yahoo.com
<s99999999s2003 at yahoo.com> wrote:
> what is the python way to concat 2 lines eg
>
> line  1 with some text
> line 2 with some text
>
> i want to bring line 2 up , such that i get one whole string.
>
> line  1 with some text line 2 with some text

line1 = "line  1 with some text"
line2 = "line 2 with some text"

# Simplest way:

line3 = line1 + line2

# More general - joining a sequence of strings, with delimiter

lines = [line1, line2]
line3 = ", ".join(lines)

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list