def func(s: str): temp = '' count = 0 for i in range(len(s)): for j in range(i + 1, len(s)): if s[i] != s[j]: break j += 1 if count < j - i: count = j - i temp = s[i:j] i = j return temp, count if __name__ == '__main__': print(func('adsgggggsdfssssssseeeee'))