写了好多遍了还是不对 怎么写呢

第一个是我把大小写已经全部转化为小写了 然后再怎么找出其中频率最高的字母呢
然后还有一道随机生成字母的
希望过程简单一点啦

img

img

def count_each_char(Str):
    Dict = {}
    for i in Str:
        if i not in Dict:
            Dict[i] = 1
        else:
            Dict[i] += 1
    return sorted(Dict.items(), key=lambda x: x[1], reverse=True)


S = "The Southwestern University of Finance and Economics (SWUFE) is a top univers"
print(S)
s = S.lower()
print(count_each_char(s))
import random

symbol = ['@', '#', '%', '&']
lower = [chr(i) for i in range(65, 91)]
upper = [chr(i) for i in range(97, 123)]
number = [str(i) for i in range(0, 10)]
s_sym = random.choices(symbol)
s_low = random.choices(lower)
s_upp = random.choices(upper)
s_num = random.choices(number)
l = random.randint(8, 12)
s_oth = random.choices(symbol + upper + lower + number, k=l - 4)
s = ''.join(random.sample(s_sym + s_upp + s_low + s_num + s_oth, k=l))
print(s)