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

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

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

s = input()

for i in s :
    if not i.isdigit():
        s = s.replace(i,' ')

s = s.split(' ')
m = 0
res = ''

for i in s:     # s= ['8', '72', '6', '5', '98', '65', '1', '2']
    if len(i) > m:
        m = len(i)

for i in s:       
    if len(i) == m:
        res = res + i       # 字符串连接
print(str(res) + ',' + str(m))

全部评论

相关推荐

求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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