题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
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
查看9道真题和解析