How to Join a List into a String in Python

· 1 min read · Updated March 17, 2026 · beginner
python strings lists beginner

Converting a list to a string is one of the most common operations in Python. The str.join() method is the standard way to do this.

Basic Usage

The join() method concatenates elements of an iterable into a single string:

words = ["hello", "world", "python"]
result = " ".join(words)
print(result)  # hello world python

Joining Strings

When your list contains strings, join() works directly:

fruits = ["apple", "banana", "cherry"]
", ".join(fruits)  # "apple, banana, cherry"

"#".join(["a", "b", "c"])  # "a#b#c"

Joining Numbers

Numbers must be converted to strings first:

numbers = [1, 2, 3, 4, 5]
# Wrong: ",".join(numbers)  # TypeError!
# Correct:
", ".join(str(n) for n in numbers)  # "1, 2, 3, 4, 5"

# Or using map:
", ".join(map(str, numbers))  # "1, 2, 3, 4, 5"

Common Patterns

CSV-style output

data = ["name", "email", "phone"]
",".join(data)  # "name,email,phone"

File path construction

parts = ["home", "user", "documents", "file.txt"]
"/".join(parts)  # "home/user/documents/file.txt"

List to comma-separated

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

Edge Cases

  • Empty list: "".join([]) returns ""
  • Single element: "".join([“x”]) returns “x”
  • List with None: Filter out None values first
mixed = ["a", None, "b", None, "c"]
" ".join(filter(None, mixed))  # "a b c"

Summary

  • Use separator.join(iterable) to combine list elements
  • Elements must be strings—convert numbers with str()
  • Works with any iterable, not just lists