题解 | #在字符串中找出连续最长的数字串#

在字符串中找出连续最长的数字串

https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec

while True:
    try:
        a = input()
        a_list = [i for i in a]
        for i in range(len(a_list)):
            if a_list[i].isalpha():
                a_list[i] =  ' '
        a_str = ''.join(a_list).split()
        Long = [len(i) for i in a_str]
        out_str = []
        for i in a_str:
            if len(i) == max(Long):
                out_str.append(i)
        print(''.join(out_str) + ',' + str(max(Long)))
    except:
        break

全部评论

相关推荐

浩浩没烦恼:一二面加起来才一个小时? 我一面就一个小时多了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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