题解 | #字符串归一化#python

字符串归一化

https://www.nowcoder.com/practice/6d5e036defdf408681376a4a9d4930ff

st=input()
dic={} # 用于记录每个字符的个数
for s in st:
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
res=''
l=sorted(dic) # sorted()函数传入字典,默认使用键排序生成列表
for v in l:
    res+=(v+str(dic[v]))
print(res)

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-20 14:14
点赞 评论 收藏
分享
05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务