题解 | #统计字符#
统计字符
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)