当前位置:网站首页>Calculate the number of occurrences of a character
Calculate the number of occurrences of a character
2022-04-23 15:40:00 【Ye Ningxia Xin】
describe
Write a program , Accept a letter from 、 A string of numbers and spaces , And a character , Then output the number of occurrences of the character in the input string .( Case insensitive )
Data range : 1 \le n \le 1000 \1≤n≤1000
Input description :
On the first line, enter a string of letters and numbers and spaces , Enter a character on the second line .
Output description :
The number of characters in the output input string .( Case insensitive )
Example 1
Input :ABCabc A
Output :2
Their thinking : loop
content = input()
content1 = content.upper()
ch = input()
ch1 = ch.upper()
num = 0
for i in content1:
if i == ch1:
num += 1
print(num)
notes :b = list(a.lower()) # Convert all input characters to lowercase letters
b = list(a.upper()) # Convert all input characters to uppercase letters
版权声明
本文为[Ye Ningxia Xin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231534071671.html
边栏推荐
猜你喜欢
随机推荐
怎么看基金是不是reits,通过银行购买基金安全吗
字符串最后一个单词的长度
小程序知识点积累
CVPR 2022 优质论文分享
Connect PHP to MySQL via PDO ODBC
控制结构(一)
For examination
KNN, kmeans and GMM
Advantages, disadvantages and selection of activation function
服务器中毒了怎么办?服务器怎么防止病毒入侵?
Connect PHP to MSSQL via PDO ODBC
Mysql database explanation (10)
YML references other variables
推荐搜索 常用评价指标
字节面试 transformer相关问题 整理复盘
Machine learning - logistic regression
G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction
为啥禁用外键约束
Modèle de Cluster MySQL et scénario d'application
深度学习调参的技巧