>>> def stat_string():
while True:
s = input('请输入:')
if s:
unique = list(set(s))
cs = [s.count(ch) for ch in unique]
n_max = max(cs)
while cs.count(n_max) > 0:
i = cs.index(n_max)
ch_max = unique[i]
print(ch_max, n_max)
cs[i] -= 1
else:
break
>>> stat_string()
请输入:ddff345
f 2
d 2
请输入:ddff3344555
5 3
请输入:
>>>
>>> def stat_string():
while True:
s = input('请输入:')
if s:
ch_max = max(set(s), key=s.count)
print(ch_max, s.count(ch_max))
else:
break
>>> stat_string()
请输入:dffdgdfgssdsd324234
d 5
请输入:sdfgsdbxcbsdfg78237402
d 3
请输入:gfhfalkwerwe8888128
8 5
请输入:
>>>