convert string>>dictionary >>list >> string
input_new = list ( string2 ) sort_list = input_new . sort () d = { x : input_new . count ( x ) for x in input_new } l = [] for key , value in d . items (): l . append ( key ) l . append ( str ( value )) print ( '' . join ( l ))