Q:

make a number of lines of string into one long line in python

Say i had the string:
string = '''
this line number 1
line 2
line 3
line 4
'''

How would you make it into:
this is line number 1line 2line 3line4

Does anyone know?

A:

Use join and splitlines:
>>> string = '''
... this line number 1
... line 2
... line 3
... line 4
... '''
>>> ''.join(string.splitlines())
'this line number 1line 2line 3line 4'

This is better than a .replace("\n", "") because it deals with \r\n and \n:
>>> "".join("a\r\nb\nc".splitlines())
'abc'
>>> "a\r\nb\nc".replace("\n", "")
'a\rbc'

