human
Length of the longest substring that do not contain any palindrome | Function to find the length of the longest substring.
initializing the variables.
checking palindrome of size 2 example : aa.
checking palindrome of size 3 example : aba.
else : incrementing length of substring.
If there exits single character then it is always palindrome.
Driver Code"
Solution in Python:
 ... Write me a code to length of the longest substring that do not contain any palindrome and the other steps required?
assistant
#Here is code to length of the longest substring that do not contain any palindrome and the other steps required.
 def lenoflongestnonpalindrome ( s ) :
	max1 , length = 1 , 0
	for i in range ( 0 , len ( s ) - 1 ) :
		if s [ i ] == s [ i + 1 ] :
			length = 0
		elif s [ i + 1 ] == s [ i - 1 ] and i > 0 :
			length = 1
			length += 1
	if max1 == 1 :
		return 0
	else :
		return max1
if __name__ == " _ _ main _ _ " :
	s = " synapse "
	print ( lenoflongestnonpalindrome ( s ) )