From 188ba6574cd94dcdcc721860326c415a02b47e59 Mon Sep 17 00:00:00 2001 From: Blaise Pabon <254456+blaisep@users.noreply.github.com> Date: Wed, 4 Nov 2026 11:30:15 -0500 Subject: [PATCH] gh-106318: Add an example for `str.capitalize()` (GH-134272) (cherry picked from commit c3e24227320515456dc8a9e1cb88503fab5d0191) Co-authored-by: Blaise Pabon <254456+blaisep@users.noreply.github.com> Co-authored-by: Adorilson Bezerra Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/builtins/stdtypes.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Doc/builtins/stdtypes.rst b/Doc/builtins/stdtypes.rst index 91f149f8d1c382..1eb284b8097593 100644 --- a/Doc/builtins/stdtypes.rst +++ b/Doc/builtins/stdtypes.rst @@ -1858,13 +1858,23 @@ expression support in the :mod:`re` module). .. method:: str.capitalize() Return a copy of the string with its first character capitalized and the - rest lowercased. + rest lowercased. For example: + + .. doctest:: + + >>> 'PYTHON IS AMAZING'.capitalize() + 'Python is amazing' + >>> 'Njemačka starts With a non-ASCII digraph'.capitalize() + 'Njemačka starts with a non-ascii digraph' + + See also :meth:`title`. .. versionchanged:: 3.8 The first character is now put into titlecase rather than uppercase. This means that characters like digraphs will only have their first letter capitalized, instead of the full character. + .. method:: str.casefold() Return a casefolded copy of the string. Casefolded strings may be used for