题解 | #密码截取#

密码截取

https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1

import sys

 
while 1:
    try:
        date=input()
       
        n=len(date)
        l=[]
        for i in range(n-1):            
            for x in range(n-1,0,-1):             
                if date[i]==date[x]:                                                  
                    if date[i:x+1]==date[i:x+1][::-1]:
                        l.append(len(date[i:x+1]))
                    else:
                        continue
                else:
                    continue
       
        print(sorted(l,reverse=True)[0])
    except:
        break

全部评论

相关推荐

05-20 21:57
已编辑
门头沟学院 Java
喜欢吃卤蛋的悲伤蛙在...:建信融通没消息吧,我2说有实习挂简历不理了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 13:15
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务