How to Print a New Line in Python (Including After a Variable)

Python’s print() ends every call with a new line, so printing a new line in Python usually means doing nothing extra. Call print() on its own for a blank line, or put \n inside the text:

print("First line")
print()                      # blank line
print("Line one\nLine two")

The details trip people up, though, starting with print("\n") giving two line breaks. Every output here is a real run on Python 3.14.7.

Diagram of how Python print joins values with sep and adds end, and why printing a newline gives two line breaks
print() glues the values together with sep and adds end, which is a new line by default.

Print a new line in Python with print()

Here’s the basic behavior, with nothing but print():

print("First line")
print("Second line")
print()                        # an empty print() is a blank line
print("After a blank line")
print("Line one\nLine two")    # \n inside the string

Output:

First line
Second line

After a blank line
Line one
Line two

Each print() call lands on its own line because it ends with a new line automatically. A bare print() with no arguments prints just that new line, which shows up as a blank line.

Inside a string, \n starts a new line wherever you put it. That’s how one print() call produces two lines of output.

The \n character itself, and everything you can do with it in strings, is covered in the guide to the Python newline character.

How to break a line in Python (output versus code)

“Break a line” can mean two different things, and people mix them up. One is a line break in what gets printed; the other is splitting a long line of code:

print("This message is long enough that I split it "
      "over two lines of code, but it prints on one line.")
print()

print("This one has a real line break\n"
      "because the first part ends with \\n.")

Output:

This message is long enough that I split it over two lines of code, but it prints on one line.

This one has a real line break
because the first part ends with \n.

Two strings side by side inside the parentheses are joined into one, with no line break, so the first message prints on a single line. Only the \n in the second call breaks the output.

I split long print() calls this way all the time. Wrapping the pieces in parentheses keeps the code readable without changing what’s printed.

Print a new line after a variable in Python

This is the question most people land here with. The short answer: you usually don’t need to do anything, because print() already moves to the next line.

name = "Ava"
city = "Austin"
total = 42.5

print(name)                    # print() already ends the line
print(city)
print()

print(f"Name: {name}\nCity: {city}\nTotal: ${total:.2f}")
print()

print(name, city, total, sep="\n")    # one value per line

Output:

Ava
Austin

Name: Ava
City: Austin
Total: $42.50

Ava
Austin
42.5
Command Prompt showing Python printing variables each on a new line with print, an f-string and sep
Three ways to put variables on separate lines: separate calls, \n in an f-string, and sep="\n".

Separate print() calls are the simplest. An f-string with \n between the values builds the whole block in one call, which is handy for a receipt or a summary.

sep="\n" is the neat one for several variables. It tells print() to put a new line between the values instead of a space.

Mixing text and variables on one line is a topic of its own, covered in printing a string and a variable.

Print a new line inside an f-string

\n works anywhere in the text part of an f-string. Inside the curly braces it’s a newer feature:

import sys

states = ["California", "Texas", "New York"]
total = 3

print(f"States:\n{'\n'.join(states)}\nTotal: {total}")
print()

nl = "\n"                                  # works on every Python 3 version
print(f"States:{nl}{nl.join(states)}{nl}Total: {total}")
print()
print("ran on", sys.version.split()[0])

Output:

States:
California
Texas
New York
Total: 3

States:
California
Texas
New York
Total: 3

ran on 3.14.7

Putting '\n'.join(...) inside the braces works on Python 3.12 and later. On 3.11 and older it’s a SyntaxError, so if your code has to run there, store the new line in a variable first, like nl.

I still use the variable version in code that other people run, since you can’t always control which Python they have installed.

Why print("\n") gives you two new lines

This is the most common surprise. You ask for one new line and get two:

import io, contextlib

print("Before")
print("\n")                    # meant as one new line
print("After")
print()

buffer = io.StringIO()
with contextlib.redirect_stdout(buffer):
    print("\n")
print("print('\\n') actually wrote:", repr(buffer.getvalue()))

name = "Ava"
buffer = io.StringIO()
with contextlib.redirect_stdout(buffer):
    print(f"{name}\n")
print("print(f'{name}\\n') wrote:  ", repr(buffer.getvalue()))

Output:

Before


After

print('\n') actually wrote: '\n\n'
print(f'{name}\n') wrote:   'Ava\n\n'
Command Prompt showing Python print with a newline character writing two line breaks instead of one
print("\n") writes your \n plus its own, so there are two blank lines between Before and After.

print() adds its own \n after whatever you pass. So print("\n") writes your line break and then another one, and the capture shows '\n\n'.

The same thing happens when you end an f-string with \n. print(f"{name}\n") leaves a blank line after the name, which may or may not be what you wanted.

For one blank line, use a bare print(). There’s more on blank lines in skipping a line in Python.

Print each list item on a new line

Printing a list shows the brackets and commas. To get one item per line instead, there are three good options:

states = ["California", "Texas", "New York"]

print(*states, sep="\n")
print()
print("\n".join(states))
print()
for number, state in enumerate(states, start=1):
    print(f"{number}. {state}")
print()

prices = [19.99, 5, 42.5]
print(*prices, sep="\n")       # numbers are fine here
try:
    print("\n".join(prices))
except TypeError as err:
    print("TypeError:", err)

Output:

California
Texas
New York

California
Texas
New York

1. California
2. Texas
3. New York

19.99
5
42.5
TypeError: sequence item 0: expected str instance, float found
Command Prompt showing Python printing each list item on a new line with sep, join and a loop
print(*items, sep="\n") works for any values; join() needs strings.

print(*states, sep="\n") unpacks the list into separate arguments and puts a new line between them. It’s my go-to, because it works with numbers too.

"\n".join() builds one string first, which is useful when you want to store or return the text. It only accepts strings, which is why the price list raised a TypeError.

A loop is the choice when each line needs extra formatting, like the numbered list. Printing a list without brackets covers more layouts.

Control line endings with end and sep in print()

Two keyword arguments decide what print() puts between values and after them, and the end parameter is the one you’ll use most:

print("Loading", end="")
print("...", end="")
print(" done")                 # the default end is "\n"
print()

print("a", "b", "c")           # the default sep is a space
print("a", "b", "c", sep=", ")
print("a", "b", "c", sep="\n")
print()

print("Two blank lines follow", end="\n\n\n")
print("next")

try:
    print("x", end=5)
except TypeError as err:
    print("TypeError:", err)

Output:

Loading... done

a b c
a, b, c
a
b
c

Two blank lines follow


next
TypeError: end must be None or a string, not int
Command Prompt showing the Python print end and sep parameters and the TypeError when end is not a string
end replaces the final new line; sep replaces the space between values.

end is what comes after the output, and it’s "\n" by default. Setting end="" keeps the next print() on the same line, which is how the loading line was built in three calls.

sep goes between the values. The default is a single space, and it can be any string, including a comma or a new line.

Both must be strings. end=5 raises TypeError: end must be None or a string, not int, while None just means the default.

Staying on one line is its own topic, with progress bars and more, in printing on the same line in Python.

Is there a println in Python?

No. If you’re coming from Java, Python’s print() already behaves like println:

try:
    println("Hello")
excep