Use string index() to find the substring index value. This method returns the index of a substring inside the string (if found).
string.index(value, start, end)
Get substring index value in Python
Simple example code finds substring index value if found and else it raises an exception. Using index() function With Substring argument Only.
text = 'Python is development' res = text.index('is') print(res)
Using start and end Arguments
text = 'Python is programing or is fun' res = text.index('is', 15, 30) print(res)
Do comment if you have any doubts and suggestions on this Python substring topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.