#leetcode题
class Solution(object):
def longestPalindrome(self, s):
n=len(s)
s1=''
for i in range(n-1,-1,-1):
s1+=s[i] #建立一个和原字符串对称的字符串
max1=''
#找对称字符串和原字符串中公共的最长字符串同时要满足条件下标相对应
for i in range(0,n):
lp=''
for x in range(i,n):
lp+=s[x]
if lp in s1 :
if len(lp)>len(max1) and s1.find(lp)+len(lp)+i==n :
max1=lp
else:
break
return max1