题解 | 统计字符

统计字符

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

str1 = input()
numcha = 0
numnull = 0
numnumber = 0
numelse = 0
for ss in str1:
    if 65 <= ord(ss) <= 90 or 97 <= ord(ss) <= 122:
        numcha = numcha + 1
    elif ord(ss) == 32:
        numnull = numnull + 1
    elif 48 <= ord(ss) <= 57:
        numnumber = numnumber + 1
    else:
        numelse = numelse + 1
print(numcha,numnull,numnumber,numelse,sep = '\n')


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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