python3 最长代码

while True:
    try:
        dic = {}
        s = input()
        lst = []
        res = []
        for i in s:
            if i in dic:
                dic[i] +=1
            else:
                dic[i] = 1
        for i in dic.values():
            if i not in lst:
                lst.append(i)
            else:
                continue
        for i in sorted(lst,reverse=True):
            tmp = []
            for j in s:
                if dic[j] == i:
                    if j in tmp:
                        continue
                    else:
                        tmp.append(j)
            res.append(sorted(tmp))
        for i in res:
            for j in i:
                print(j,end='')       
    except:
        break