def longestPalindromeSubstring(str) :
size = len(str)
longestLength = 1
start = 0
i = 0
while (i < size) :
j = i
while (j < size) :
palindrome = 1
k = 0
while (k < int((j - i + 1) / 2)) :
if (str[i + k] != str[j - k]) :
palindrome = 0
k += 1
if (palindrome != 0 and (j - i + 1) > longestLength) :
start = i
longestLength = j - i + 1
j += 1
i += 1
print("Longest palindrome substring = ", end ="")
i = start
while (i <= start + longestLength - 1) :
print(str[i], end ="")
i += 1
print("\n", end ="")
return longestLength
s = "qabcbaproggorpxyyxzv"
result = longestPalindromeSubstring(s)
print("Length palindrome substring length = " + str(result))
'''
run:
Longest palindrome substring = proggorp
Length palindrome substring length = 8
'''