题解 | #统计字符#

统计字符

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

# 没有统计中文也对啊 
string = input()
l = 0 
n = string.__len__()
num = 0
block = 0
other = 0
letter = 0
import re
while l < n:
    c = string[l]
    l  += 1
    if  c == ' ':
        block += 1
        continue
    elif re.findall(r'\d', c):
        num += 1
        continue
    elif re.findall(r'[A-Za-z]', c):
        letter += 1
        continue
    else:
        other += 1
        continue
print(letter)
print(block)
print(num)
print(other)
        
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务