You are viewing a single comment's thread. Return to all comments →
from collections import Counter if __name__ == '__main__': s = input() c = Counter(s) sort_val = sorted(c.values(), reverse=True) #nos. sorted in ascending order sort_counter = dict(sorted(c.items())) #sorted the counter i = 0 while(i<3): for k,v in sort_counter.items(): if v==sort_val[i]: print(k +" "+ str(v)) sort_counter.pop(k) i+=1 break
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 →