当前位置:网站首页>计算某字符出现次数
计算某字符出现次数
2022-04-23 15:34:00 【叶宁夏昕】
描述
写出一个程序,接受一个由字母、数字和空格组成的字符串,和一个字符,然后输出输入字符串中该字符的出现次数。(不区分大小写字母)
数据范围: 1 \le n \le 1000 \1≤n≤1000
输入描述:
第一行输入一个由字母和数字以及空格组成的字符串,第二行输入一个字符。
输出描述:
输出输入字符串中含有该字符的个数。(不区分大小写字母)
示例1
输入:ABCabc A
输出:2
解题思路:循环
content = input()
content1 = content.upper()
ch = input()
ch1 = ch.upper()
num = 0
for i in content1:
if i == ch1:
num += 1
print(num)
注释:b = list(a.lower()) #将输入的字符全部转换为小写字母
b = list(a.upper()) #将输入的字符全部转换为大写字母
版权声明
本文为[叶宁夏昕]所创,转载请带上原文链接,感谢
https://blog.csdn.net/come_bn/article/details/124274282
边栏推荐
- GFS distributed file system (Theory)
- Mysql连接查询详解
- Modify the default listening IP of firebase emulators
- What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
- HJ31 单词倒排
- c语言---字符串+内存函数
- 【Leetcode-每日一题】安装栅栏
- Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
- [leetcode daily question] install fence
- PHP 的运算符
猜你喜欢

Detailed explanation of kubernetes (XI) -- label and label selector

【Leetcode-每日一题】安装栅栏

TLS / SSL protocol details (28) differences between TLS 1.0, TLS 1.1 and TLS 1.2

Kubernetes详解(九)——资源配置清单创建Pod实战

Byte interview programming question: the minimum number of K

Tun model of flannel principle

MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器

Mysql连接查询详解

激活函数的优缺点和选择

Explanation 2 of redis database (redis high availability, persistence and performance management)
随机推荐
What are the mobile app software testing tools? Sharing of third-party software evaluation
PHP PDO ODBC将一个文件夹的文件装载到MySQL数据库BLOB列,并将BLOB列下载到另一个文件夹
控制结构(一)
Grep was unable to redirect to the file
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
KNN, kmeans and GMM
Tun model of flannel principle
X509 certificate cer format to PEM format
Crawling fragment of a button style on a website
Baidu written test 2022.4.12 + programming topic: simple integer problem
通过 PDO ODBC 将 PHP 连接到 MSSQL
今日睡眠质量记录76分
Openstack command operation
群体智能自主作业智慧农场项目启动及实施方案论证会议
G007-HWY-CC-ESTOR-03 华为 Dorado V6 存储仿真器搭建
Mysql database explanation (10)
木木一路走好呀
The wechat applet optimizes the native request through the promise of ES6
使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群
Mysql database explanation (VII)