7-8 sdut-统计工龄- 字典排序

使用sorted函数

n=int(input())
num=[int(x) for x in input().split()]
mp={}
for i in num:
    mp.setdefault(i,0)
    mp[i]=mp[i]+1

for i,j in sorted(mp.items()):
    print("{}:{}".format(i,j))
posted @ 2022-06-08 16:24  kingwzun  阅读(26)  评论(0编辑  收藏  举报