Python String Index() Method Syntax
Syntax: string_obj.index(substring, start, end)
Parameters:
- substring: The string to be searched for.
- start (default : 0) : This function specifies the position from where the search has to be started.
- end (default: length of string): This function specifies the position from where the search has to end.
Return: Returns the first position of the substring found.
Exception: Raises ValueError if the argument string is not found or the index is out of range.
Python String index() Method
Python String index() Method allows a user to find the index of the first occurrence of an existing substring inside a given string in Python.