题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
s = input()
alp_n, spa_n, num_n, other_n = 0, 0, 0, 0
for i in s:
if i.isalpha():
alp_n += 1
elif i == ' ':
spa_n += 1
elif i.isdigit():
num_n += 1
else:
other_n += 1
print(alp_n)
print(spa_n)
print(num_n)
print(other_n)


查看10道真题和解析