Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt

Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt_第1张图片

def lon(s):
    outString = ""
    while len(s) > len(outString):
        indLen = len(outString)
        temp = s[: indLen]
        for ch in s[indLen:]:
            temp += ch
            print(temp)
            if temp == temp[::-1]:
                outString = temp if len(temp) > len(outString) else outString
        s = s[1:]
    return outString
lon('okllkk')

 

你可能感兴趣的:(python)