Result Size:
625 x 571
demo_ref_string_find_vs_index.py:
txt = "Hello, welcome to my world." print(txt.find("q")) print(txt.index("q"))
x
txt
=
"Hello, welcome to my world."
print
(
txt
.
find
(
"q"
))
print
(
txt
.
index
(
"q"
))
C:\Users\My Name>python demo_string_find_vs_index.py
-1
Traceback (most recent call last):
File "demo_ref_string_find_vs_index.py", line 4 in <module>
print(txt.index("q"))
ValueError: substring not found