How to Remove Newlines in Python
- 1). Open your Python editor.
- 2). Type:
s = 'This is my text string with a line break\n'
s.rstrip('\n') - 3). Press "Enter."
Python removes the newline and returns:
'This is my text string with a line break'
Source...