牛客网华为机试在线训练————计算字符个数
程序如下:
str0 = input()
str1 = input()
str0 = str0.lower()
str1 = str1.lower()
count = 0
for i in str0:
if i == str1:
count = count + 1
print(count)
在判断字符相等时,i ==str1时,遇到问题,本来使用is进行判断,后来经过查询,得知:
is 是判断两个变量引用的是否为同一个值:
==是判断两个变量的值是否相等。
网友评论