Free tools Windows power users keep installed
One-click scans. No signup required.
Use separator.join(items) when the list contains strings and you want them combined with a chosen separator. If the values include numbers or other types, convert each value to a string first, for example with map(str, items). Use str(items) only when you want the list’s printable representation, including its brackets and quotes.
Join a list of strings with a separator
Call join() on the separator you want between elements:
names = ["Ada", "Grace", "Linus"]
result = ", ".join(names)
print(result) # Ada, Grace, Linus
The separator is inserted between adjacent strings; it is not added before the first item or after the last. An empty string produces no separator, a space produces space-separated values, and a newline separates values onto different lines. Python’s built-in types documentation defines str.join(iterable) as returning a string made by concatenating the strings in an iterable.
Convert numbers and mixed values before joining
join() requires every item to be a string. A list containing an integer, boolean, or bytes object raises TypeError rather than converting that item automatically.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors#1 Best Overall
values = ["age", 42, True]
result = ", ".join(map(str, values))
print(result) # age, 42, True
map(str, values) applies str() to each value as it is consumed. A generator expression is another way to express the conversion:
result = ", ".join(str(value) for value in values)
For a list of integers, for example, ", ".join(map(str, [1, 2, 3])) produces "1, 2, 3". Choose the separator to match the format you need.
Rank #2
Choose between str(), map(), and a list comprehension
| Approach | Output or behavior | When to use it |
|---|---|---|
", ".join(items) |
Combines string elements with comma-space separators. | Every item is already a string and you want a delimiter-separated result. |
str(items) |
Returns the list’s printable representation, including list syntax such as brackets and quotes. | You want a representation of the list itself, not a custom-delimited sequence. |
", ".join(map(str, items)) |
Converts each item to a string as it is consumed, then joins the results. | Items may have different types and you want a concise conversion pipeline. |
", ".join(str(x) for x in items) |
Uses a generator expression to provide converted strings as needed. | You want the conversion to be explicit inline without building a temporary list. |
", ".join([str(x) for x in items]) |
Builds a new list of strings before joining. | You also need to keep or inspect the converted list. |
In Python 3, map() returns an iterator. Generator expressions likewise compute values as needed; list comprehensions materialize a new list. The Python Functional Programming HOWTO describes these differences. They affect intermediate storage, but do not establish that one approach is universally faster.
Why str(list) is not the same as joining
These operations produce different kinds of strings:
items = ["x", "y"]
print(str(items)) # ['x', 'y']
print(", ".join(items)) # x, y
str(items) shows a representation of the list, with its container syntax. join() combines the element strings using the separator you chose and omits the brackets and quotes around the list.
Build a string from many fragments
If a loop produces many pieces, collect them and join once rather than repeatedly extending an immutable string:
parts = []
for value in values:
parts.append(str(value))
result = " ".join(parts)
The Python Programming FAQ cautions that repeated concatenation can be inefficient: in the general case, total runtime cost can be quadratic in the total string length. Its recommended idiom is to put the strings into a list and call str.join at the end. See the Python Programming FAQ.
Handle nested lists deliberately
join() does not recursively flatten nested lists. If an element is itself a list, converting it with str() produces that inner list’s representation. Decide how nested values should be flattened or formatted before joining; do not expect join() to infer the intended output.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
Best Value
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.




