How to Remove Newlines in Python

104 12
    • 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...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.