Function Details: index_(str)

Description


Returns the lowest index where the substring is found.


Extended Description


The index() method returns the lowest index in the string where the substring is found. If the substring is not found, it raises a ValueError. Optional start and end parameters can be used to limit the search to a specific slice of the string. The search is performed from left to right.


Function Signature


str.index(sub: str, start: int = 0, end: int = None) -> int

Module: str

Class: str

Parameters



Parameter List


  • sub: str
  • start: int
  • end: int

Return


Returns an integer representing the lowest index where the substring is found.


Return Type


int

Output

Explanation

This example shows finding the index of substrings in the string.