join()
Joins list elements into a single string.
Syntax
separator.join(items)
Description
The opposite of split(). Joins a string array by placing a separator between them. Note: separator first, items inside parentheses.
Returns
The joined string.
Example
Loading editor…
Expected output
2024-10-02 code learn
When to use?
Converting list data into a single-line text (date, path, sentence).
Common mistakes
- ⚠️ If the list contains numbers, first convert them to str(): '-'.join(map(str, numbers)).