题解 | #密码截取#
密码截取
http://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1
mima = str(input()) longest = 0 length = len(mima) for j in range(0,length): count_1 = 0 count_2 = 0 while(j+count_1<length and j-count_1>=0 and mima[j-count_1] == mima[j+count_1]): count_1 += 1 while(j+count_2+1<length and j-count_2>=0 and mima[j-count_2] == mima[j+count_2+1] ): count_2 += 1 if(longest <= max((count_1*2-1),(count_2*2))): longest = max((count_1*2-1),(count_2*2)) print(longest)