4095: 【例7.2】统计几种字符个数
内存限制:128 MB
时间限制:1.000 S
评测方式:文本比较
命题人:
提交:1
解决:1
题目描述
输入一行字符,分别统计英文字母、空格、数字和其他字符的4种个数。
输入
输入一行字符,包含英文字母、空格、数字和其他字符。
输出
输出字符统计的个数,每行1种。
样例输入 复制
Python 3.6.0中文版
样例输出 复制
6
1
3
5
提示
a_list=list(input()) letter=[] space=[] number=[] other=[] for i in range(len(a_list)): if ord(a_list[i]) in range(65,91) or ord(a_list[i]) in range(97,123): letter.append(a_list[i]) elif a_list[i]==' ': space.append(' ') elif ord(a_list[i]) in range(48,58): number.append(a_list[i]) else: other.append(a_list[i]) print(len(letter)) print(len(space)) print(len(number)) print(len(other))