demo_ref_string_find_vs_index.py:
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