Skip to content

Commit 3dd7a3c

Browse files
authored
gh-106318: Add example for str.isalnum() (#137550)
1 parent cfeede8 commit 3dd7a3c

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
@@ -2180,7 +2180,18 @@ expression support in the :mod:`re` module).
21802180
Return ``True`` if all characters in the string are alphanumeric and there is at
21812181
least one character, ``False`` otherwise. A character ``c`` is alphanumeric if one
21822182
of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``,
2183-
``c.isdigit()``, or ``c.isnumeric()``.
2183+
``c.isdigit()``, or ``c.isnumeric()``. For example::
2184+
2185+
.. doctest::
2186+
2187+
>>> 'abc123'.isalnum()
2188+
True
2189+
>>> 'abc123!@#'.isalnum()
2190+
False
2191+
>>> ''.isalnum()
2192+
False
2193+
>>> ' '.isalnum()
2194+
False
21842195

21852196

21862197
.. method:: str.isalpha()

0 commit comments

Comments
 (0)