Skip to content

Commit 4c1c99e

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 9e46e1b commit 4c1c99e

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
@@ -2222,7 +2222,16 @@ expression support in the :mod:`re` module).
22222222
Return a string which is the concatenation of the strings in *iterable*.
22232223
A :exc:`TypeError` will be raised if there are any non-string values in
22242224
*iterable*, including :class:`bytes` objects. The separator between
2225-
elements is the string providing this method.
2225+
elements is the string providing this method. For example:
2226+
2227+
.. doctest::
2228+
2229+
>>> ', '.join(['spam', 'spam', 'spam'])
2230+
'spam, spam, spam'
2231+
>>> '-'.join('Python')
2232+
'P-y-t-h-o-n'
2233+
2234+
See also :meth:`split`.
22262235

22272236

22282237
.. method:: str.ljust(width, fillchar=' ', /)
@@ -2436,6 +2445,8 @@ expression support in the :mod:`re` module).
24362445
>>> " foo ".split(maxsplit=0)
24372446
['foo ']
24382447

2448+
See also :meth:`join`.
2449+
24392450

24402451
.. index::
24412452
single: universal newlines; str.splitlines method

0 commit comments

Comments
 (0)