index() - Searches the string for a specified value and returns the position of where it was found

Returns the index in the given string of the first matching substring.  If the index is not found, Python throws a ValueError exception.

Example

Python
str = 'The quick brown fox jumped over the lazy dog'
print(str.index('brown'))
try:
    print(str.index('horse'))
except ValueError:
    print('The string "horse" was not found!')

Output

10
The string "horse" was not found!