题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
string = input()
num_alpha, num_space, num_digit, num_other = [0] *4
for s in string:
if s.isalpha():
num_alpha += 1
elif s.isdigit():
num_digit += 1
elif s == ' ':
num_space += 1
else:
num_other += 1
print(num_alpha)
print(num_space)
print(num_digit)
print(num_other)
查看13道真题和解析