using python,
def search(in_str,sub): count = 0 firstOccr = -1 for i in range(len(in_str)): if(in_str[i:].startswith(sub)): if(firstOccr==-1): firstOccr = i count += 1 print("Number of search term exist in the text:",count) return firstOccr # Testing print("First occurrence is at index:",search("abcdecseda","e"))
Get Answers For Free
Most questions answered within 1 hours.