题解 | #统计字符#

统计字符

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

while True:
    try:
        s=input()
        alphas,digits,blanks,others=0,0,0,0
        for i in s:
            if i.isdigit():
                digits+=1
            elif i.isalpha():
                alphas+=1
            elif i == ' ':
                blanks+=1
            else:
                others+=1
        print(alphas,blanks,digits,others,sep='\n')
    except:
        break

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 18:06
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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