human
Can you provide a code to length of Longest Palindrome Substring and the other steps required given the following:
Length of Longest Palindrome Substring | Function to obtain the length of the longest palindromic substring.
Length of given string.
Stores the maximum length.
Iterate over the string.
Iterate over the string.
Check for palindrome.
If string [ i , j - i + 1 ] is palindromic.
Return length of LPS.
Given string.
Function call"
How can the above be solved in Python?
assistant
#Here is code to length of Longest Palindrome Substring and the other steps required.
 def longestPalSubstr ( str ) :
	n = len ( str )
	maxLength = 1
	start = 0
	for i in range ( len ( str ) ) :
		for j in range ( i , len ( str ) , 1 ) :
			flag = 1
			for k in range ( ( j - i + 1 ) // 2 ) :
				if ( str [ i + k ] != str [ j - k ] ) :
					flag = 0
			if ( flag != 0 and ( j - i + 1 ) > maxLength ) :
				start = i
				maxLength = j - i + 1
	return maxLength
str = " forgeeksskeegfor "
print ( longestPalSubstr ( str ) )