File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ for word in word_list:
5656>b 3
5757>a 2
5858>c 2
59+ >d 1
60+ >e 1
5961>```
6062
6163### Hints
@@ -71,10 +73,24 @@ for i in word:
7173 dct[i] = dct.get(i,0) + 1
7274
7375dct = sorted(dct.items(),key=lambda x: (-x[1],x[0]))
74- for i in dct[:3] :
76+ for i in dct:
7577 print(i[0],i[1])
7678```
7779---------------------
80+ ``` python
81+ ''' Solution by: yuan1z'''
82+
83+ X = input ()
84+ my_set = set (X)
85+ arr = []
86+ for item in my_set:
87+ arr.append([item,X.count(item)])
88+ tmp = sorted (arr,key = lambda x : (- x[1 ],x[0 ]))
89+
90+ for i in tmp:
91+ print (i[0 ]+ ' ' + str (i[1 ]))
92+ ```
93+ ---------------------
7894
7995
8096# Question 102
@@ -152,4 +168,4 @@ print(sum)
152168
153169[ *** Discussion*** ] ( https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/issues/3 )
154170
155- # To Be Continue...
171+ # To Be Continue...
You can’t perform that action at this time.
0 commit comments