human
Longest Palindromic Substring | Set 1 | Function to pra subString str [ low . . high ].
This function prints the longest palindrome subString It also returns the length of the longest palindrome.
Get length of input String.
All subStrings of length 1 are palindromes.
Nested loop to mark start and end index.
Check palindrome.
Palindrome.
Return length of LPS.
Driver Code"
Solution in Python:
assistant
#Here is code to longest Palindromic Substring and the other steps required.
 def printSubStr ( str , low , high ) :
	for i in range ( low , high + 1 ) :
		print ( str [ i ] , end = " " )
def longestPalSubstr ( str ) :
	n = len ( str )
	maxLength = 1
	start = 0
	for i in range ( n ) :
		for j in range ( i , n ) :
			flag = 1
			for k in range ( 0 , ( ( j - i ) // 2 ) + 1 ) :
				if ( str [ i + k ] != str [ j - k ] ) :
					flag = 0
			if ( flag != 0 and ( j - i + 1 ) > maxLength ) :
				start = i
				maxLength = j - i + 1
	print ( " Longest ▁ palindrome ▁ subString ▁ is : ▁ " , end = " " )
	printSubStr ( str , start , start + maxLength - 1 )
	return maxLength
if __name__ == ' _ _ main _ _ ' :
	str = " forgeeksskeegfor "
	print ( " Length is :   " , longestPalSubstr ( str ) )