python 统计字符
输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
http://www.nowcoder.com/questionTerminal/539054b4c33b4776bc350155f7abd8f5
if name =='main':
while True:
try:
s = raw_input()
i =0
num_digit = 0
num_space =0
num_alpha = 0
num_sym = 0
while i< len(s):
if s[i].isdigit():
num_digit +=1
elif s[i].isalpha():
num_alpha +=1
elif s[i] == ' ':
num_space +=1
else:
num_sym =num_sym+1
i= i+1
print num_alpha
print num_space
print num_digit
print num_sym
except:
break