题解 | #统计字符#

统计字符

https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5

text = list(input())

d={'str':0,'space':0,'num':0,'other':0}

for i in text:
    if i.isalpha():
        d['str']+=1
    elif i==' ':
        d['space']+=1
    elif i.isdigit():
        d['num']+=1
    else:
        d['other']+=1

for i,count in d.items():
    print(count)

説的對,就是硬遍历

全部评论

相关推荐

Ncsbbss:又想干活又想要工资,怎么什么好事都让你占了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务