题解 | #统计字符#python3
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
一个简单的字母提取分类
while True:
try:
str1 = str(input())
cha1 = 0
num1 = 0
space = 0
other_cha = 0
for i in str1:
if((ord(i) >= 65 and ord(i) <= 90) or (ord(i) >= 97 and ord(i) <= 122)):
cha1 += 1
elif(ord(i) >= 48 and ord(i) <= 57):
num1 += 1
elif(i == ' '):
space += 1
else:
other_cha += 1
print(cha1)
print(space)
print(num1)
print(other_cha)
except:
break
OPPO公司福利 1514人发布