题解 | #密码截取#
密码截取
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1
def palindrome(s):
for i in range(len(s)//2):
if s[i]!= s[-1*(i+1)]:
return False
return True
while True:
try:
s=input()
length=len(s)
max_len=1
for i in range(length-1):
for j in range(length,i+max_len,-1):
if palindrome(s[i:j]):
max_len=len(s[i:j])
break
print(max_len)
except:
break