【问题描述】实现一个函数 count_char, 并在主程序中调用该函数判断某字符串中包含多少个给定字符。(注意:字符串和字符都为用户输入)
【输入形式】第一个输入表示带判断的字符串;第二个输入表示某给定字符。
【输出形式】一个整型数,表示待判断的字符串中包含给定字符的数量
【样例输入】
Hello,Python
o
【样例输出】
2
【样例说明】
【评分标准】
def count_char(n,m):
b={}
for i in range (0,len(n)):
if n[i] not in b:
b[n[i]]=1
else:
b[n[i]] += 1
if m in b:
return b[m]
else:
return 0
a=input()
c=input()
d=count_char(a,c)
print(d)