L1-003 个位数统计 python

python 实现

s=str(input())

lst_s=[]
lst_info=[]
lst_num=[]
for i in s:
    if int(i) not in lst_info:
        lst_info.append(int(i))
    lst_s.append(int(i))
lst_info.sort()

for i,item in enumerate(lst_info):
    lst_num.append(lst_s.count(item))

for i,item in enumerate(lst_info):
    print("{index}:{num}".format(index=item,num=lst_num[i]))

 

posted @ 2024-07-04 21:00  豆豆是只乖狗狗  阅读(2)  评论(0编辑  收藏  举报