03- calculates the number of characters -1

Write a program that accepts a string of letters and numbers, and a character, the number of input and output of the character string contained. not case sensitive.

Python lower () method converts the string in all uppercase characters to lowercase.

Python count () method is used in a number of statistical string of characters appears.

# 方法1:
str1 = input()
str2 = input()
str1 = str1.lower()
str2 = str2.lower()
 
j = 0
for i in range(len(str1)):
    if str1[i]==str2:
        j +=1
print(j)

# 方法2:
a=input().lower()
b=input().lower()
print(a.count(b))

 

 

Guess you like

Origin www.cnblogs.com/summer1019/p/11141155.html