str1 = "helloworld"list1 = list(str1)list2 = []list3 = []dict1 = {}for i in list1: if i not in list2: list2.append(i) z = list1.count(i) list3.append(z)# print(list2)# print(list3)# print(list2[0])# print(list3[0])for a in list2: for b in list3: # print(list2.index(a),list3.index(b)) if list2.index(a)==list3.index(b): dict1.setdefault(a,b) # elif list2.index(a) > len(list3): # dict1.setdefault(a)print(dict1)
```