题解 | #统计字符#

统计字符

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

string = input()
num_alpha, num_space, num_digit, num_other = [0] *4
for s in string:
    if s.isalpha():
        num_alpha += 1
    elif s.isdigit():
        num_digit += 1
    elif s == ' ':
        num_space += 1
    else:
        num_other += 1
print(num_alpha)
print(num_space)
print(num_digit)
print(num_other)

全部评论

相关推荐

10-30 22:18
已编辑
毛坦厂中学 C++
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务