Python print examples showing newlines and blank lines

How to print a new line in Python: 3 simple ways

The simplest answer to how to print a new line in Python is to call print(): Python moves the output to the next line after each call by default. You can also place newline characters inside a string or change what print() adds after each value.

Use the default behavior for separate lines, \n for line breaks within text, an empty print() for a blank line, and end= when you need custom spacing or punctuation.

How to print a new line in Python with print()

Every print() call ends with a newline by default. That means the next call starts on the following line.

Example: print(“First”); print(“Second”)

This produces:

  • First
  • Second

To move to the next line in Python, you usually do not need a special character. Just use another print() call. The default ending is equivalent to end=”\n”, where \n represents one newline character.

How to print a newline in Python with \n

Use the \n escape sequence when you want to embed a line break inside one string. The string stores the newline character, and the terminal moves to a new line when print() displays it.

Example: print(“First\nSecond”)

The output is:

  • First
  • Second

Here, Python makes one print call, but the string contains two lines. This differs from two separate print() calls: the newline is part of the string rather than an ending automatically added by the function.

For multiple line breaks, add multiple \n characters. Two consecutive newline characters create an empty line between the other lines.

Example: print(“First\n\nSecond”)

This displays First, then a blank line, then Second.

Print a blank line with print()

Call print() with no value when you need one blank line between output sections. It prints an empty value and then its default newline.

Example: print(“Above”); print(); print(“Below”)

The result has one empty line between Above and Below. This approach is clearer than adding extra newline characters when you are separating two groups of output.

Control line endings with end=

The end parameter controls what print() adds after its value. Its default is end=”\n”. Set it to another string when you do not want the call to move to a new line.

Use end=”” to keep the next output on the same line:

Example: print(“Hello”, end=””); print(” world”)

Output: Hello world. The first call adds nothing after Hello, so the second call continues on that line.

Use end=” “ to add a space instead:

Example: print(“Hello”, end=” “); print(“world”)

You can also use punctuation or another separator:

Example: print(“A”, end=”-“); print(“B”)

This produces A-B. Choose \n for a newline inside text, an empty print() for a blank line, and end= when you need precise control over what follows each print call.