题解 | #计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
line = input() target = input().lower() times = 0 for i in line: if i.lower() == target: times += 1 print(times)
以上是一般的思路,后面如果直接用`count`函数的话,可以简化一下:
line = input().lower() target = input().lower() print(line.count(target))