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:
#1 Best Overall
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.
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.
Quick Recap
Best Value
Rank #2
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.




