Chapters
Python114 chapters

ReferenceString methods

str.join()

Glues strings together with the separator between them.

Signature

separator.join(iterable)

Parameters

NameMeans
iterablestrings to join; every item must already be a string

Returns

One new string.

Example

Python
print(", ".join(["a", "b", "c"]))
print("".join(["a", "b"]))
print(", ".join(str(n) for n in [1, 2]))

Output

a, b, c
ab
1, 2

See also