You are viewing a single comment's thread. Return to all comments →
Is better solution using Counter (as i learnt from other posting), anyway here is my solution.
from itertools import groupby
if name == 'main':
s = sorted(list(input())) cap= [(k, len(list(g))) for k, g in groupby(s) ] print (cap) res = sorted(cap, reverse=True, key=lambda qty: qty[1])
for x in range(3): print(res[x][0],res[x][1] )
Seems like cookies are disabled on this browser, please enable them to open this website
Company Logo
You are viewing a single comment's thread. Return to all comments →
Is better solution using Counter (as i learnt from other posting), anyway here is my solution.
from itertools import groupby
if name == 'main':
for x in range(3):
print(res[x][0],res[x][1] )