当前位置:网站首页>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
边栏推荐
猜你喜欢

Explanation 2 of redis database (redis high availability, persistence and performance management)

Independent operation smart farm Innovation Forum

Treatment of idempotency

服务器中毒了怎么办?服务器怎么防止病毒入侵?

Functions (Part I)

APISIX jwt-auth 插件存在错误响应中泄露信息的风险公告(CVE-2022-29266)

Machine learning - logistic regression

Modèle de Cluster MySQL et scénario d'application

KNN, kmeans and GMM

考试考试自用
随机推荐
[backtrader source code analysis 18] Yahoo Py code comments and analysis (boring, interested in the code, you can refer to)
After time judgment of date
CAP定理
Configuration of multi spanning tree MSTP
软件性能测试报告起着什么作用?第三方测试报告如何收费?
Explanation of redis database (I)
regular expression
大型互联网为什么禁止ip直连
Treatment of idempotency
Single architecture system re architecture
使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群
通过 PDO ODBC 将 PHP 连接到 MSSQL
Upgrade MySQL 5.1 to 5.69
幂等性的处理
PHP PDO ODBC将一个文件夹的文件装载到MySQL数据库BLOB列,并将BLOB列下载到另一个文件夹
计算某字符出现次数
大厂技术实现 | 行业解决方案系列教程
携号转网最大赢家是中国电信,为何人们嫌弃中国移动和中国联通?
服务器中毒了怎么办?服务器怎么防止病毒入侵?
删除字符串中出现次数最少的字符