L1-003 個位數統計 python

豆豆是只乖狗狗發表於2024-07-04

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]))

相關文章