题解 | #字符类型计数#
字符类型计数
http://www.nowcoder.com/practice/73ac4280bcfe4d64b85763e86e367e15
X = input()
alpha, digit, space, other = 0, 0, 0, 0
for i in range(len(X)):
a = ord(X[i])
if a >= 65 and a <= 90:
alpha += 1
elif a >= 97 and a <= 122:
alpha += 1
elif a >= 48 and a <= 57:
digit += 1
elif a == 32:
space += 1
else:
other += 1
print("alpha:", alpha)
print("digit:", digit)
print("space:", space)
print("other:", other)