题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
import sys #for line in sys.stdin: # a = line.split() # print(int(a[0]) + int(a[1])) #以函数的方式进行统计 def Tongji(): s = input() s = list(s) L1=[] L2=[] L3=[] L4=[] #利用Python的俩个自带的函数判断数字类型和字母类型,用排除法判断最后一种类型 for x in s: if x.isdigit(): L1.append(x) elif x.isalpha(): L2.append(x) elif x==" ": L3.append(x) else: L4.append(x) print(len(L2),len(L3),len(L1),len(L4),sep="\n") Tongji()