Print "\n" or newline characters as part of the output on terminal
Use repr
>>> string = "abcd\n"
>>> print(repr(string))
'abcd\n'
If you're in control of the string, you could also use a 'Raw' string type:
>>> string = r"abcd\n"
>>> print(string)
abcd\n
Another suggestion is to do that way:
string = "abcd\n"
print(string.replace("\n","\\n"))
But be aware that the print function actually print to the terminal the "\n", your terminal interpret that as a newline, that's it. So, my solution just change the newline in \ + n