File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1922,6 +1922,8 @@ expression support in the :mod:`re` module).
19221922
19231923 .. doctest ::
19241924
1925+ >>> ' spam, spam, spam' .index(' spam' )
1926+ 0
19251927 >>> ' spam, spam, spam' .index(' eggs' )
19261928 Traceback (most recent call last):
19271929 File "<python-input-0>", line 1, in <module>
@@ -2305,6 +2307,20 @@ expression support in the :mod:`re` module).
23052307
23062308 Like :meth: `rfind ` but raises :exc: `ValueError ` when the substring *sub * is not
23072309 found.
2310+ For example:
2311+
2312+ .. doctest ::
2313+
2314+ >>> ' spam, spam, spam' .rindex(' spam' )
2315+ 12
2316+ >>> ' spam, spam, spam' .rindex(' eggs' )
2317+ Traceback (most recent call last):
2318+ File "<stdin-0>", line 1, in <module>
2319+ 'spam, spam, spam'.rindex('eggs')
2320+ ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
2321+ ValueError: substring not found
2322+
2323+ See also :meth: `index ` and :meth: `find `.
23082324
23092325
23102326.. method :: str.rjust(width, fillchar=' ', /)
You can’t perform that action at this time.
0 commit comments