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 @@ -2163,6 +2163,8 @@ expression support in the :mod:`re` module).
21632163
21642164 .. doctest ::
21652165
2166+ >>> ' spam, spam, spam' .index(' spam' )
2167+ 0
21662168 >>> ' spam, spam, spam' .index(' eggs' )
21672169 Traceback (most recent call last):
21682170 File "<python-input-0>", line 1, in <module>
@@ -2546,6 +2548,20 @@ expression support in the :mod:`re` module).
25462548
25472549 Like :meth: `rfind ` but raises :exc: `ValueError ` when the substring *sub * is not
25482550 found.
2551+ For example:
2552+
2553+ .. doctest ::
2554+
2555+ >>> ' spam, spam, spam' .rindex(' spam' )
2556+ 12
2557+ >>> ' spam, spam, spam' .rindex(' eggs' )
2558+ Traceback (most recent call last):
2559+ File "<stdin-0>", line 1, in <module>
2560+ 'spam, spam, spam'.rindex('eggs')
2561+ ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
2562+ ValueError: substring not found
2563+
2564+ See also :meth: `index ` and :meth: `find `.
25492565
25502566
25512567.. method :: str.rjust(width, fillchar=' ', /)
You can’t perform that action at this time.
0 commit comments