Skip to content

Commit 5097311

Browse files
adorilsonStanFromIreland
authored andcommitted
gh-106318: Add examples for str.join() (GH-140315)
(cherry picked from commit fb65552) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent a676b2e commit 5097311

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Doc/library/stdtypes.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,16 @@ expression support in the :mod:`re` module).
20862086
Return a string which is the concatenation of the strings in *iterable*.
20872087
A :exc:`TypeError` will be raised if there are any non-string values in
20882088
*iterable*, including :class:`bytes` objects. The separator between
2089-
elements is the string providing this method.
2089+
elements is the string providing this method. For example:
2090+
2091+
.. doctest::
2092+
2093+
>>> ', '.join(['spam', 'spam', 'spam'])
2094+
'spam, spam, spam'
2095+
>>> '-'.join('Python')
2096+
'P-y-t-h-o-n'
2097+
2098+
See also :meth:`split`.
20902099

20912100

20922101
.. method:: str.ljust(width, fillchar=' ', /)
@@ -2300,6 +2309,8 @@ expression support in the :mod:`re` module).
23002309
>>> " foo ".split(maxsplit=0)
23012310
['foo ']
23022311

2312+
See also :meth:`join`.
2313+
23032314

23042315
.. index::
23052316
single: universal newlines; str.splitlines method

0 commit comments

Comments
 (0)