How to Print a Line Break in Python

A line break is a full line of whitespace, which can be useful for formatting output data.

 

To create a line break in Python, use the \n statement. Put this anywhere within a string where you would like the line break to start.

 

text = "one line\nanother line"

print(text)
one line
another line

 

Here is another example with a line break at the end of a string:

 

text = "One line\n"
text_2 = "Another line"

print(text + text_2)
One line
Another line