- index
- ValueError
index in string
examples/strings/index.py
text = "The black cat climbed the green tree." print(text.index("bl")) # 4 print(text.index("The")) # 0 print(text.index("the")) # 22 print(text.index("dog"))
4
0
22
Traceback (most recent call last):
File "index.py", line 5, in <module>
print(text.index("dog"))
ValueError: substring not found