Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.
>>> 'spam, spam, spam'.index('spam') 0 >>> 'spam, spam, spam'.index('eggs') Traceback (most recent call last): File "<python-input-0>", line 1, in <module> 'spam, spam, spam'.index('eggs') ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ ValueError: substring not found
builtins/str.index
str.index