Python – How to print a string without including ‘\n’ in Python

pythonstring

Suppose my string is:

' Hai Hello\nGood eve\n'

How do I eliminate the '\n' in between and make a string print like :

 Hai Hello Good eve 

?

Best Solution

If you don't want the newline at the end of the print statement:

import sys
sys.stdout.write("text")