《python语言程序设计》2018版第8章第6题统计字符串中的字母个数
代码段
def count_letters(s):
len_num =len(s)
b = random.randint(1,len_num)
text_show = s[b]
a_time = s.count(text_show)
return f"{text_show} is in {s}, {a_time} times."
str_text = "welcome to shenyang"
a = count_letters(str_text)
print(a)