编写count函数统计给定字符串中特定字符的出现次数

编写函数count,统计给定字符串中大写字母、小写字母、数字字符及其他字符的出现次数。

import string

def count(s):
    d = {}
    for i in s:
        if i in string.ascii_uppercase:
            d['big'] = d.get('big', 0) + 1
        elif i in string.ascii_lowercase:
            d['small'] = d.get('small', 0) + 1
        elif i in string.digits:
            d['digit'] = d.get('digit', 0) + 1
        else:
            d['other'] = d.get('other', 0) + 1
    return d

res = count('asUO223aswoe  w2347(*&*(')

print(res)
'''--result
{'small': 8, 'big': 2, 'digit': 7, 'other': 7}
'''

遍历 用ASSIC码判断大小写和数字
计数输出