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

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

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

while True:
    try:
        s = input()
        tmp = ''
        for i in s:
            if i.isdigit():
                tmp += i
            else:
                tmp += ' '
        l = tmp.split()
        M = max([len(i) for i in l])
        res = ''
        for i in l:
            if len(i) == M:
                res += i
        print(f"{res},{M}")
    except:
        break

全部评论

相关推荐

2 1 评论
分享
牛客网
牛客企业服务