The index() method returns the index where a substring exists in the string.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
str1 = "Jason Stanson is the most famous actor in Hollywood.!!!"
str2='is'
print (str1.index(str2))
print (str1.index(str2, 5))
Output:
14
14
Syntax
str.index(sub[, start[, end]] )
Parameters
Name | Description |
sub | Substring to be searched in the string str. |
Return Value
It returns the lowest index in the string where the substring is found.