当前位置:网站首页>计算某字符出现次数
计算某字符出现次数
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
边栏推荐
- utils.DeprecatedIn35 因升级可能取消,该如何办
- 电脑怎么重装系统后显示器没有信号了
- Tun model of flannel principle
- pgpool-II 4.3 中文手册 - 入门教程
- 使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群
- 考试考试自用
- 编译,连接 -- 笔记
- Multitimer V2 reconstruction version | an infinitely scalable software timer
- Today's sleep quality record 76 points
- 移动app软件测试工具有哪些?第三方软件测评小编分享
猜你喜欢

pgpool-II 4.3 中文手册 - 入门教程

Cookie&Session

函数(第一部分)

cadence SPB17.4 - Active Class and Subclass

WPS品牌再升级专注国内,另两款国产软件低调出国门,却遭禁令

网站压测工具Apache-ab,webbench,Apache-Jemeter

API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)

Demonstration meeting on startup and implementation scheme of swarm intelligence autonomous operation smart farm project

Sword finger offer (2) -- for Huawei

c语言---字符串+内存函数
随机推荐
Byte interview programming question: the minimum number of K
tcp_ Diag kernel related implementation 1 call hierarchy
Grep was unable to redirect to the file
Pytorch中named_parameters、named_children、named_modules函数
MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
调度系统使用注意事项
ICE -- 源码分析
深度学习——超参数设置
Nacos program connects to mysql8 0+ NullPointerException
The El tree implementation only displays a certain level of check boxes and selects radio
Detailed explanation of MySQL connection query
Explanation of redis database (I)
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
Use of common pod controller of kubernetes
About UDP receiving ICMP port unreachable
Adobe Illustrator menu in Chinese and English
基础贪心总结
C language super complete learning route (collection allows you to avoid detours)
YML references other variables
使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群