October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Convert a List to a String in Python: join(), map(), and More

Use join() to combine string elements with a chosen separator. For mixed values, convert each item with map(str) or a generator expression first.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.