题解 | 统计字符
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
import sys s = input() count = [0, 0, 0, 0] # 初始化四个计数器 a = "qwertyuioplkjhgfdsazxcvbnm" b = " " c = "1234567890" for i in s: if i in a: count[0] += 1 # 字母 elif i in b: count[1] += 1 # 空格 elif i in c: count[2] += 1 # 数字 else: count[3] += 1 # 其他字符 for i in range(4): print(count[i])