题解 | #统计字符#

统计字符

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

ent = input()
list_ent = list(ent)
eng_count = 0
kong_count = 0
num_count = 0
qita_count = 0
for i in list_ent:
    asc = ord(i)
    if 65 <= asc <= 90 or 97 <= asc <= 122:
        eng_count += 1
    elif asc == 32:
        kong_count += 1
    elif 48 <= asc <= 57:
        num_count += 1
    else:
        qita_count += 1
print(eng_count,kong_count,num_count,qita_count,sep='\n')

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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