Skip to content

Commit 95ea035

Browse files
committed
[Doc] Added examples for str.join()
1 parent bedaea0 commit 95ea035

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Doc/library/stdtypes.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,16 +2186,21 @@ expression support in the :mod:`re` module).
21862186
False
21872187

21882188

2189-
2190-
.. _meth-str-join:
2191-
21922189
.. method:: str.join(iterable, /)
21932190

21942191
Return a string which is the concatenation of the strings in *iterable*.
21952192
A :exc:`TypeError` will be raised if there are any non-string values in
21962193
*iterable*, including :class:`bytes` objects. The separator between
21972194
elements is the string providing this method.
21982195

2196+
For example:
2197+
2198+
.. doctest::
2199+
>>> ', '.join(['spam', 'spam', 'spam'])
2200+
'spam, spam, spam'
2201+
>>> '-'.join('Python')
2202+
'P-y-t-h-o-n'
2203+
21992204

22002205
.. method:: str.ljust(width, fillchar=' ', /)
22012206

0 commit comments

Comments
 (0)