Find Substring Index in String

  • Share this:

Code introduction


This function is used to find the index of the substring `sub` in the string `s` and returns the position index. If the substring does not exist, it returns -1.


Technology Stack : String (str), find

Code Type : String lookup function

Code Difficulty :


                
                    
def string_find_index(s, sub):
    index = s.find(sub)
    return index                
              
Tags: