Skip to content

Commit 6cef3c2

Browse files
authored
Update Day_24.md
1 parent 3d627c5 commit 6cef3c2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Status/Day_24.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff 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
7375
dct = 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...

0 commit comments

Comments
 (0)