Skip to content

Commit ecd9956

Browse files
committed
[Doc] Added examples for str.join()
1 parent f7111d8 commit ecd9956

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
@@ -2173,16 +2173,21 @@ expression support in the :mod:`re` module).
21732173
False
21742174

21752175

2176-
2177-
.. _meth-str-join:
2178-
21792176
.. method:: str.join(iterable, /)
21802177

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

2183+
For example:
2184+
2185+
.. doctest::
2186+
>>> ', '.join(['spam', 'spam', 'spam'])
2187+
'spam, spam, spam'
2188+
>>> '-'.join('Python')
2189+
'P-y-t-h-o-n'
2190+
21862191

21872192
.. method:: str.ljust(width, fillchar=' ', /)
21882193

0 commit comments

Comments
 (0)