两层循环

while True:
	try:
		s = input()
		l = len(s)
		max_ = 0
		dic = {}

		for i, c in enumerate(s):
			if '0' <= c <= '9':
				k = i
				sub = ''
				while k < l and '0' <= s[k] <= '9':
					sub += s[k]
					k += 1
				n = len(sub)
				if n > max_:
					max_ = n
				if n in dic:
					dic[n].append(sub)
				else:
					dic[n] = [sub]

		print(''.join(dic[max_])+','+str(max_))
	except:
		break