当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
How to test mobile app?
pywintypes.com_error: (-2147221020, ‘无效的语法‘, None, None)
时序模型:门控循环单元网络(GRU)
导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
考试考试自用
Demonstration meeting on startup and implementation scheme of swarm intelligence autonomous operation smart farm project
Single architecture system re architecture
Why disable foreign key constraints
MySQL集群模式与应用场景
【Leetcode-每日一题】安装栅栏
软件性能测试报告起着什么作用?第三方测试报告如何收费?
Neodynamic Barcode Professional for WPF V11.0
For examination
Introduction to dynamic programming of leetcode learning plan day3 (198213740)
幂等性的处理
Treatment of idempotency
一刷314-剑指 Offer 09. 用两个栈实现队列(e)
Neodynamic Barcode Professional for WPF V11. 0
Go语言切片,范围,集合
码住收藏▏软件测试报告模板范文来了