Google is your friend. See this question. You need something like this:
text = text.replace('\n', ' ')