October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Python print() End Parameter: Print Without a Newline

Python print() adds a newline by default. Use its end parameter to omit that newline or replace it with a space or other string.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python’s built-in print() adds a newline after its output by default. Set end="" to add nothing, or end=" " to add a space, controlling where the next output begins.

What does the end parameter do?

The built-in function has this signature:

print(*objects, sep=' ', end='n', file=None, flush=False)

Python’s built-in reference describes it this way: “Print objects to the text stream file, separated by sep and followed by end.” In other words, print() writes its objects, then writes the value of end. The default, 'n', moves subsequent output to a new line.

As an Amazon Associate I earn from qualifying purchases.

The end, sep, file, and flush options are keyword arguments. end and sep accept a string or None; passing None selects the respective default. Even a call with no objects writes its end value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I print without a newline?

Pass an empty string as end. This omits the usual newline, so the next output continues immediately after the first:

print("Hello", end="")
print("world")

The output is Helloworld on one line. The second call uses its default newline, so output after world begins on the following line.

How do I keep output on the same line with a space?

Use end=" " to put a space after each printed value instead of a newline. For example:

for value in [1, 2, 3]:
    print(value, end=" ")
print()

The loop writes 1 2 3 on one line, including a trailing space after 3. The final print() writes its default newline, moving any subsequent output to the next line.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Python input and output tutorial uses end=' ' to print table values in segments before the final value in each row. For a sequence where no separator is wanted between calls, use end="" instead.

How is end different from sep?

sep controls what goes between multiple objects in a single call; end controls what comes after all of them. For example:

print("red", "green", "blue", sep=", ", end="!")

This writes red, green, blue!: the comma and space separate the objects, while the exclamation mark is the ending text. Neither setting changes the other.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What do file and flush change?

file selects the text stream that receives the output; by default, it is sys.stdout. flush=True forces that stream to flush. These options affect the destination or handling of the output, not the suffix supplied by end. print() writes text; for a file opened in binary mode, use the file object’s write() method instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For the accepted arguments and full behavior, see the Python built-in function reference. The IDLE documentation also illustrates print(s, end='') with the comment “Display s as is.”

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.