题解 | #统计字符#

统计字符

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

my_str = input()
letter_count = 0
number_count = 0
space_count = 0
other_count = 0

for char in my_str.strip():
    if char.isalpha():
        letter_count += 1
    elif char.isnumeric():
        number_count += 1
    elif char.isspace():
        space_count += 1
    else:
        other_count += 1

print(letter_count)
print(space_count)
print(number_count)
print(other_count)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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