题解 | #统计字符#
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
while True:
try:
s = input()
dic = {
'letter' : 0,
'space' : 0,
'num' : 0,
'other' : 0
}
for c in s:
if c.isalpha():
dic['letter'] += 1
elif c == ' ':
dic['space'] += 1
elif c.isdigit():
dic['num'] += 1
else:
dic['other'] += 1
for k in ['letter', 'space', 'num', 'other']:
print(dic[k])
except:
break
老板电器公司氛围 197人发布