题解 | #使用字典计数#

使用字典计数

https://www.nowcoder.com/practice/74f7e7f2344f4754bc56d862838cbfc3

str1=input('')

word=[]
num=[]
for x in str1:
    if x not in word:
        word.append(x)
for y in word:
    count=0
    for z in str1:
        if(y==z):
            count +=1
    num.append(count)
print(dict(zip(word,num)))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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