classSolution(object): defstrStr(self, haystack, needle): """ :type haystack: str :type needle: str :rtype: int """ haystack_len = len(haystack) needle_len = len(needle) for i in range(haystack_len-needle_len+1): match = True for k in range(needle_len): if haystack[i+k] != needle[k]: match = False break if match isTrue: return i return-1