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

计算某字符出现次数

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


全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 14:10
点赞 评论 收藏
分享
每晚夜里独自颤抖:要求太多的没必要理
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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