题解 | 统计字符

统计字符

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')


全部评论

相关推荐

在看牛客的社畜很积极:身高体重那一行信息去掉,学校那一行的信息放上面,找半天都没找到你是哪个学校什么专业的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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