当前位置:网站首页>Introduction to isalpha () method
Introduction to isalpha () method
2022-06-29 18:57:00 【It's Joe Joe】
Introduce
str.isalpha() The implementation is to return if the string has at least one character and all characters are letters True, Otherwise return to False.
application :
for example ACM There is a sorting problem in the algorithm :
Write a program , Sort the characters in the input string as follows .
The rules 1 : The English letters come from A To Z array , Case insensitive .
Such as , Input : Type Output : epTy
The rules 2 : When the case of the same English letter exists at the same time , Sort according to the input order .
Such as , Input : BabA Output : aABb
The rules 3 : Other characters other than English letters remain in their original position .
Such as , Input : By?e Output : Be?y
Data range : The length of the input string meets the requirements 1 \le n \le 1000 \1≤n≤1000
Input description :
Input string
Output description :
Output string
Input :A Famous Saying: Much Ado About Nothing (2012/8).
Output :A aaAAbc dFgghh: iimM nNn oooos Sttuuuy (2012/8)
Code :
while True:
try:
s = input()
a = ''
for i in s:
if i.isalpha(): # Make letter type judgment
a += i
b = sorted(a, key=str.upper) # According to capitalization ASC Sort code
index = 0
d = ''
for i in range(len(s)):
if s[i].isalpha():
d += b[index]
index += 1
else:
d += s[i]
print(d)
except:
break
边栏推荐
- layer.prompt
- Data warehouse model layered ODS, DWD, DWM practice
- [Nanjing University] information sharing of the first and second postgraduate entrance examinations
- PostGIS generate graphic cut
- Redis(一)--Redis入门(2)--Redis数据类型
- 移动端测试
- garbage collector
- Source code installation mavros
- JS converts seconds to "2h30min50s" format
- Dragon canvas animation
猜你喜欢

JWT login authentication

How to use the low code platform of the Internet of things for service management?

报错Failed to allocate graph: MYRIAD device is not opened.

深度学习---三好学生各成绩所占权重问题(2)

Mac: MySQL 66 questions, 20000 words + 50 pictures!

75.二叉搜索树额最近公共祖先

对强缓存和协商缓存的理解

Redis(一)--Redis入门(2)--Redis数据类型

Several code screenshots beautification tools worth collecting by programmers

程序员值得收藏的几款代码截图美化工具播
随机推荐
JWT登录验证
JS judge whether the array key name exists
优雅书写Controller(参数验证+统一异常处理)
Shandong University project training (VII) add navigation bar to select city
什么是多范式编程语言,其中的“多范式”是什么意思?
SD6.24集训总结
信息系统项目管理师---第七章项目成本管理历年考题
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
svg画圆路径动画
Sd6.24 summary of intensive training
Adobe Premiere foundation - time remapping (10)
Meta agent model can be migrated to resist attacks
Adobe Premiere foundation - opacity (mixed mode) (XII)
Selenium WebDriver的高级特性
元素等待机制
Shandong University project training (VIII) design rotation map entry page
MySQL 企业级开发规范
Anaconda安装并配置jupyter notebook远程
74.股票的最大利润
龙canvas动画