输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
"""
name: wzl
date: 2020/2/27
task: 输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
"""
x = str(input('please enter whatever you want: '))
alpha = 0
digit = 0
space = 0
others = 0
for i in x:
if i.isdigit():
digit += 1
elif i.isalpha():
alpha += 1
elif i.isspace():
space += 1
else:
others += 1
print(f'alpha:{alpha} digit:{digit} space:{space} others:{others}')
please enter whatever you want: 321!!abbc cc
alpha:6 digit:3 space:1 others:2
来源:CSDN
作者:secx=1_cosx
链接:https://blog.csdn.net/ziluuu/article/details/104575012