题解 | #字符类型计数#
字符类型计数
http://www.nowcoder.com/practice/73ac4280bcfe4d64b85763e86e367e15
# 输出结果冒号后面有一个空格!!
get_str = input()
alpha = 0
digit = 0
space = 0
other = 0
for i in get_str:
if i == ' ':
space += 1
elif i in ['0','1','2','3','4','5','6','7','8','9']:
digit += 1
elif i.isalpha():
alpha += 1
else:
other += 1
print(f'alpha: {alpha}')
print(f'digit: {digit}')
print(f'space: {space}')
print(f'other: {other}')