题解 | #统计字符#

统计字符

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

import sys,string

for line in sys.stdin:
    a = line.strip()
    list1 = list(string.ascii_lowercase)
    list2 = ['0','1','2','3','4','5','6','7','8','9']
    countlist1,countlist2,countspace,countother = 0,0,0,0
    for i in a:
        if i in list1:
            countlist1 +=1
        elif i in list2:
            countlist2 +=1
        elif i == ' ':
            countspace +=1
        else:
            countother +=1
    print(countlist1)
    print(countspace)
    print(countlist2)
    print(countother)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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