You are viewing a single comment's thread. Return to all comments →
def find_count(inp_str): str_len = len(inp_str) d = {} for s in inp_str: s_count = 0 if s not in d: d.update({s: 1}) else: d[s] = d[s] + 1 d = dict(sorted(d.items(), key=lambda item: item[1], reverse=True)) l1 = [] for x in d: temp_lst = [] temp_lst.append(x) temp_lst.append(d[x]) l1.append(temp_lst) d1 = OrderedDict() for x in range(len(l1)-1): j = x + 1 while (j < len(l1)): if l1[x][1] == l1[j][1] and l1[x][0] > l1[j][0]: temp = l1[j] l1[j] = l1[x] l1[x] = temp j = j + 1 elif l1[x][1] == l1[j][1] and l1[x][0] < l1[j][0]: j = j + 1 else: break for i in l1: d1.update({i[0]: i[1]}) return d1
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 →