题解 | #统计字符#

统计字符

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

有点懒,直接用string模块的字符集去处理判断拉倒,无脑干

from string import ascii_letters, digits, punctuation, whitespace

while True:
    try:
        l_count, d_count, p_count, w_count = 0, 0, 0, 0
        for x in input():
            if x in ascii_letters:
                l_count += 1
            elif x in digits:
                d_count += 1
            elif x in punctuation:
                p_count += 1
            elif x in whitespace:
                w_count += 1
        print(l_count)
        print(w_count)
        print(d_count)
        print(p_count)
    except EOFError:
        break


全部评论

相关推荐

06-11 13:34
门头沟学院 C++
offe从四面八方来:我真的没时间陪你闹了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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