题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
astr = input() alpha_re = 0 space_re = 0 digit_re = 0 other_re = 0 for cha in astr: if cha.isalpha(): alpha_re += 1 elif cha == ' ': space_re += 1 elif cha.isdigit(): digit_re += 1 else: other_re += 1 print(alpha_re) print(space_re) print(digit_re) print(other_re)