4.计算传入函数的字符串中, 数字、字母、空格以及其他内容的个数,并返回结果。

s1 = 'wan%$#(gwdwq\nwdhuaiww3  w02041718'
def func1(s1):
    dic = {'digit': 0, 'alpha': 0, 'space': 0, 'other': 0}
    for s in s1:
        if s.isdigit():
            dic['digit'] += 1
        elif s.isalpha():
            dic['alpha'] += 1
        elif s.isspace():
            dic['space'] += 1
        else:
            dic['other'] += 1
    return dic
print(func1(s1))