题解 | 统计字符

统计字符

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

a = input()
n = len(a)
cnt1,cnt2,cnt3,cnt4=0,0,0,0
for i in range(n):
    temp = ord(a[i])
    if 65<=temp<=90 or 97<=temp<=122:
        cnt1 += 1
    elif temp == 32:
        cnt2 += 1
    elif 48<=temp<=57:
        cnt3 += 1
    else:
        cnt4+= 1
print(cnt1,cnt2,cnt3,cnt4,sep="\n")

全部评论

相关推荐

挣K存W养DOG:他的价值在于把他家里积攒的财富回馈给社会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务