You are viewing a single comment's thread. Return to all comments →
def my_func(s): chars_dict = {} str_list = list(s) for char in str_list: if char in chars_dict: chars_dict[char] += 1 else: chars_dict[char] = 1 return chars_dict if __name__ == "__main__": s = input() norm_list = my_func(s).items() srtd_norm_list = sorted(norm_list) sorted_data = sorted(srtd_norm_list, key=lambda x: x[1], reverse=True) counter = 0 for i, j in sorted_data: print(f"{i} {j}") counter += 1 if counter == 3: 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 →