def find_index(text, pattern):
    """Return the starting index of the first occurrence of pattern in text,
    or None if not found. C++ way of checking the chars in the string method used.
    Run time: O(n*m), n is length of the string, m is for if statement to check
    match is found.
    Space Complexity: O(1) because I am accessing the array indexes, it takes O(1)
    and doesn't create a new memory as opposed to pyhton slicing. 
    declaring 3 variable takes constant space in the memory"""
    assert isinstance(text, str), 'text is not a string: {}'.format(text)
    assert isinstance(pattern, str), 'pattern is not a string: {}'.format(text)
    
    if pattern == "":
        return 0
    
    starter = 0 # the starting index of the patterin in the text
    index = 0 # index for text
    subindex = 0 # index for pattern 


    while index <= len(text) - 1:

        if text[index] == pattern[subindex]:
            index += 1
            subindex +=1

            if subindex == len(pattern): # check for if we checked all index of patter  
                # starter index of the text where pattern occured 1st time
                return starter  

        else: # mismatch found 
            starter += 1 # shift the starter to next index
            index = starter 
            subindex = 0 # reset the subindex 
        
    return None