一个简单的字母提取分类

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