Run ❯
Get your
own Python
server
Result Size:
625 x 565
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
txt = "Hello, welcome to my world." print(txt.rfind("q")) print(txt.rindex("q"))
x
txt
=
"Hello, welcome to my world."
print
(
txt
.
rfind
(
"q"
))
print
(
txt
.
rindex
(
"q"
))
-1
Traceback (most recent call last):
File "demo_ref_string_rfind_vs_rindex.py", line 4 in <module>
print(txt.rindex("q"))
ValueError: substring not found