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

计算某字符出现次数

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

def call_input():
    return input()


def HJ2(string, stringIn):
    # 返回stringIn出现在string中的次数
    count = 0
    for i in range(len(string)):
        if string[i:i + len(stringIn)][0].casefold() == stringIn[0].casefold():
            count += 1
    return count


# 测试
print(HJ2(call_input(), call_input()))

全部评论

相关推荐

顺利毕业的鸽子:这个不一定,找hr跟进一下
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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