String Methods

str.join()

Join strings from an iterable, placing the receiver between adjacent elements, never before the first or after the last. Empty input produces an empty string. Non-string elements raise TypeError; convert deliberately with str() if appropriate. A string argument is itself an iterable of code points. The original string is unchanged.

Formal Syntax & Structure

python syntaxpython
text.join(iterable, /)

Parameters & Attributes

NameTypeDescription
iterableIterable[str]Iterable producing string elements.

Return Value

str

Concatenation with the receiver as separator.

Working Example

Example Snippetpython
print(" / ".join(["draft", "review", "done"]))print(",".join(str(n) for n in (2, 4, 6)))print("-".join("سلام"))
Python Reference