PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchIn an ordinary Python string, write n where you want an LF (line-feed) character. When you pass that string to print(), Python displays the line break. The backslash and n are escape notation in your source code; they are not two separate characters in the resulting string.
Insert a line break with n
Place the escape sequence inside a quoted string at the point where the next line should begin:
As an Amazon Associate I earn from qualifying purchases.
message = 'First line.nSecond line.'
print(message)
Output:
First line.
Second line.
The value stored in message has an LF character between the period and Second. print() renders that character as a line break. The same works with double quotes:
message = "First line.nSecond line."
print(message)
Python’s official tutorial explains that print() omits the enclosing quotes and prints escaped and special characters in readable form. The Python 3.14.8 language reference defines n as ASCII Linefeed (LF).
#1 Best Overall
Why a REPL or debugger may show n
A string’s representation is designed to show its contents unambiguously, so it may display the escape spelling n instead of rendering a line break. That does not mean the string lacks a newline. Compare the representation with printed output:
message = 'First line.nSecond line.'
repr(message)
print(message)
The representation contains the visible escape spelling; the final call to print() displays the two lines. Use print() when you want to see how the text renders, and inspect the representation when you need to distinguish special characters from ordinary text.
Rank #2
Keep the literal backslash and n
If the string should contain the two visible characters backslash and n, prevent Python from interpreting them as a newline. In an ordinary string literal, double the backslash:
Recommended Free Tools
print('The escape is \n')
Or use a raw string literal:
print(r'The escape is n')
Both print The escape is n on one line. In the first example, \ in the source literal contributes one backslash to the value, followed by the letter n. In the second, the r prefix means the backslash is not interpreted as an escape. Python’s language reference documents both ordinary and raw string escape behavior.
Use triple quotes for multiline source text
A triple-quoted string can span physical lines in your Python file. Choose this when it is clearer to write the content across source lines rather than place an explicit n inside a one-line literal:
message = '''First line.
Second line.'''
print(message)
This string contains a physical newline between the two lines of source text, and print() displays it as a line break. Use n when you want the break marked at a specific point inside a quoted line; use triple quotes when the multiline layout is easier to read. The language reference describes multiline string literals.
n is not r
Python defines n as ASCII Linefeed (LF) and r as ASCII Carriage Return (CR). They are distinct escape sequences, not interchangeable names for the same character. For a basic Python string line break, use n; do not assume CR and LF behave identically in every file format, protocol, or platform.
A backslash at the end of a source line is different
A backslash followed by a physical newline in a string literal is not the same as writing n. The language reference identifies backslash-newline as an ignored end of line in the relevant literal context. To put an LF character in the string, write the escape sequence n within the literal, or include a physical newline in a triple-quoted string.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




