def find_index(text, pattern, index=0):
    """Return the starting index of the first occurrence of pattern in text,
    or None if not found.
    O(N*M) where n is length of text and M is the length of the pattern"""
    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 index
    
    while index < len(text):
        if text[index]  == pattern[0]:
            j = index
            for letter in pattern:
                if j > len(text) - 1 or text[j] != letter:
                    break
                j += 1
            else:
                return index

        index += 1
    return None