题解 | #计算某字符出现次数#

计算某字符出现次数

https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

st1 = input().lower()
st2 = input().lower()
print(st1.count(st2))
#直接使用count

思路2:遍历比较
while True:
    try:
        # 第一行输入字符串(字母,数字,空格组成)
        ss=input()
        # 第二行输入字符
        s=input()
        # 输出字符串中含字符的个数(不区分大小写)
        c=0
        for i in ss:
            if i.lower()==s.lower():
                c+=1
        print(c)
    except:
        break


全部评论

相关推荐

03-04 07:14
门头沟学院 C++
后测速成辅导一两个月...:老板:都给工作机会了还想要工资,哪来这么多好事
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务