October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk1 min

Print Characters in a String Separated by Spaces in Python

Put a space between Python string elements with `" ".join(text)`, or pass them directly to `print()` with `sep=" "`.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use " ".join(text) to put a space between the elements of a Python string, then print the result:

text = "Python"
print(" ".join(text))

Output:

P y t h o n

How the join method inserts spaces

str.join(iterable) combines strings from an iterable, placing the string before .join() between successive elements. Because a Python string is iterable, " ".join(text) puts one space between its elements. The Python built-in types documentation shows the same behavior with '-'.join('Python'), which produces P-y-t-h-o-n.

To use a different delimiter, replace the space inside the quotes. For example, "-".join(text) inserts hyphens rather than spaces.

Alternative: pass characters directly to print

If you only need to write the separated elements to standard output, unpack the string into print() and set its separator:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
text = "Python"
print(*text, sep=" ")

The * passes the string’s elements as separate arguments; sep=" " tells print() to put a space between those arguments. See the Python tutorial’s input and output section for print formatting.

Which approach should you use?

Approach Use it when What it does
print(" ".join(text)) You want the conventional join idiom or need the separated result as a string. Builds one string with a space between successive elements, then prints it.
print(*text, sep=" ") You only need to send the separated elements directly to output. Passes the elements as separate print arguments and inserts the specified separator.

What happens with empty or short strings?

  • An empty string produces no characters to join, so the result is empty.
  • A one-character string has no separator because there are no successive elements between which to insert one.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A note about Unicode characters

Python string iteration works on string elements, which do not always correspond to what a person sees as one displayed character. Combining marks and some emoji can involve multiple code points. The examples here cover ordinary strings such as "Python"; they do not provide grapheme-aware segmentation for those Unicode cases.

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 *

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.