题解 | #统计字符#

统计字符

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

s = input()
lst = [0, 0, 0, 0]  # 0:字符,1:空格,2:数字,3:其他字符

for i in s:
    lst[0] += int(i.isalpha())
    lst[1] += int(i == ' ')
    lst[2] += int(i.isnumeric())

lst[3] += len(s) - lst[0] - lst[1] - lst[2]

for i in lst:
    print(i)

全部评论

相关推荐

fRank1e:吓得我不敢去外包了,但是目前也只有外包这一个实习,我还要继续去吗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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