How to Join Strings in Python

If you want to combine text in Python, there are a few simple ways to do it.

On this page, you will learn:

  • How to join two or more strings into one string
  • How to add separators like spaces, commas, or dashes
  • When to use +, str.join(), or f-strings
  • How to avoid common string joining errors

Quick answer #

words = ["Python", "is", "fun"]
result = " ".join(words)
print(result)

Output:

Python is fun

Use str.join() when you want to combine many strings with a separator like a space, comma, or dash.

What this page helps you do #

  • Join two or more strings into one string
  • Add a separator such as a space, comma, or dash
  • Choose the right method for simple and larger cases
  • Avoid common string joining errors

Use + to join a small number of strings #

The + operator is the simplest way to join strings.

It is best when:

  • You are joining just two or three strings
  • You want to learn the basic idea first
  • You do not mind adding separators yourself

Example: join two strings #

first = "Hello"
second = "World"

result = first + second
print(result)

Output:

HelloWorld

There is no space between the words because + only combines the exact strings you give it.

Example: add a space yourself #

first = "Hello"
second = "World"

result = first + " " + second
print(result)

Output:

Hello World

Important rule #

Both sides of + must be strings.

This works:

name = "Sam"
message = "Hello " + name
print(message)

This does not work:

age = 25
message = "Age: " + age
print(message)

That raises a TypeError because Python cannot add a string and an integer directly.

To fix it, convert the number first with str():

age = 25
message = "Age: " + str(age)
print(message)

Use str.join() to join many strings #

Use str.join() when you already have a list or tuple of strings.

This is the most common and useful way to join many strings.

Basic pattern #

separator.join(items)
  • separator is the text you want between each item
  • items is a list or tuple of strings
  • The result is one new string

Example: join with spaces #

words = ["Python", "is", "fun"]
result = " ".join(words)
print(result)

Output:

Python is fun

Example: join with commas #

items = ["apple", "banana", "orange"]
result = ", ".join(items)
print(result)

Output:

apple, banana, orange

Example: join with dashes #

parts = ["2026", "04", "22"]
result = "-".join(parts)
print(result)

Output:

2026-04-22

Important rule #

All items must be strings.

This works:

items = ["a", "b", "c"]
print(", ".join(items))

This does not work:

items = ["a", 2, "c"]
print(", ".join(items))

If your list contains numbers, convert them first:

numbers = [1, 2, 3]
result = ", ".join([str(n) for n in numbers])
print(result)

Output:

1, 2, 3

If you need help with this error, see how to fix TypeError: sequence item 0: expected str instance.

How separators work #

The separator is the string before .join().

Python places that separator between items, not after the last item.

Space separator #

items = ["red", "green", "blue"]
print(" ".join(items))

Output:

red green blue

Comma and space separator #

items = ["red", "green", "blue"]
print(", ".join(items))

Output:

red, green, blue

No separator #

items = ["P", "y", "t", "h", "o", "n"]
print("".join(items))

Output:

Python

No extra separator at the end #

items = ["a", "b", "c"]
print("-".join(items))

Output:

a-b-c

Notice that the result is a-b-c, not a-b-c-.

When to use f-strings instead #

Use f-strings when you want to build a sentence with variables.

They are often easier to read than many + operators, especially when mixing text and numbers.

Example: using + #

name = "Maya"
score = 95

message = "Student: " + name + ", Score: " + str(score)
print(message)

Example: using an f-string #

name = "Maya"
score = 95

message = f"Student: {name}, Score: {score}"
print(message)

Output:

Student: Maya, Score: 95

F-strings are a good choice for formatted output and readable sentences.

If you want to learn more, see how to format strings in Python.

Common errors when joining strings #

Here are some common mistakes beginners run into.

1. join() gets non-string items #

Problem:

items = ["a", 1, "b"]
print(", ".join(items))

Why it happens:

  • join() only accepts strings
  • The integer 1 is not a string

Fix:

items = ["a", 1, "b"]
print(", ".join([str(item) for item in items]))

2. Using + with a string and integer #

Problem:

count = 3
message = "Count: " + count
print(message)

Fix:

count = 3
message = "Count: " + str(count)
print(message)

3. Forgetting separators #

Problem:

first = "Python"
second = "Beginner"
print(first + second)

Output:

PythonBeginner

Fix:

print(first + " " + second)

4. Calling join() on the wrong thing #

This is a very common mistake:

items = ["a", "b", "c"]
print(items.join(", "))

This does not work because join() is a string method.

Correct version:

items = ["a", "b", "c"]
print(", ".join(items))

Simple rule for beginners #

A good rule is:

  • Use + for very small string combinations
  • Use join() for lists of strings
  • Use f-strings when inserting variables into text
  • Convert numbers first when needed

If you remember just one thing, remember this:

  • + is fine for a few strings
  • join() is best for many strings in a list

Common mistakes #

These are the most common causes of string joining problems:

  • Trying to join a list that contains integers or other non-string values
  • Using + with a string and an integer
  • Writing items.join(",") instead of ",".join(items)
  • Expecting join() to add a separator at the end

If your code is not working, these quick checks can help:

print(type(value))
print(items)
print([type(item) for item in items])
print(', '.join([str(item) for item in items]))

What these help you check:

  • print(type(value)) shows what type a variable really is
  • print(items) shows the actual list contents
  • print([type(item) for item in items]) helps you find non-string items
  • print(', '.join([str(item) for item in items])) tests a safe conversion to strings

FAQ #

How do I join a list of strings in Python? #

Use string.join(), such as:

my_list = ["Learn", "Python"]
print(" ".join(my_list))

What is the difference between + and join()? #

+ is fine for a small number of strings.

join() is better when you want to combine many strings from a list or tuple.

Why does join() give a TypeError? #

join() only works with strings. Convert numbers or other values first using str().

How do I join strings without spaces? #

Use an empty separator:

items = ["a", "b", "c"]
print("".join(items))

Can I join numbers with join()? #

Not directly. Convert them first:

numbers = [1, 2, 3]
print(", ".join([str(n) for n in numbers]))

See also #

Press Esc to close