题解 | #密码截取#
密码截取
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1
n = input().strip() def palindrome(s, left, right): while left >= 0 and right len(s) and s[left] == s[right]: left -= 1 right += 1 return s[left + 1:right] res = "" for i in range(len(n)): s1 = palindrome(n, i, i) s2 = palindrome(n, i, i + 1) res = s1 if len(res) len(s1) else res res = s2 if len(res) len(s2) else res print(len(res))