当前位置:网站首页>String segment combination
String segment combination
2022-06-29 02:19:00 【Long street 395】
describe
Get an input string s, Minus sign with character (-) Division s, Use the plus sign for the first and last paragraphs (+) Combined output .
I / O example
Example Input Output
| Example 1 | Alice-Bob-Charis-David-Eric-Flurry | Alice+Flurry |
s = input()
ls = s.split("-")
print("{}+{}".format(ls[0], ls[-1]))s.split(k) With k Split for tag s, Generate a list . Pass the title , master split() Use of methods , Be careful :k It can be a single character , It could be a string .
It can also be in this form :
a = input()
k=""
for i in a:
if i == "-":
break
else:
k +=i
j=""
a = a[::-1]
for i in a:
if i == "-":
break
else:
j +=i
j = j[::-1]
print(k+"+"+j)
边栏推荐
- Chrome browser close update Popup
- Com3529 test analysis
- 11 go Foundation: Interface
- How to become a senior digital IC Design Engineer (6-7) digital IC Verification: debug skills
- KOA Quick Start
- How to become a senior digital IC Design Engineer (6-5) digital IC Verification: coverage collection
- 如何成为一名高级数字 IC 设计工程师(4-3)脚本篇:C 语言实现的文件读写操作
- How to become a senior digital IC Design Engineer (3-5) tools: Spyglass Technology
- [understanding of opportunity -33]: seeing is not necessarily true. Most of the time, "seeing is false"
- Learning Tai Chi Maker - mqtt Chapter II (IX) test of this chapter
猜你喜欢

Koa quick start

【Redis】List类型
![[understanding of opportunity -33]: seeing is not necessarily true. Most of the time,](/img/60/703a5bc3038d28bcf812415032f240.jpg)
[understanding of opportunity -33]: seeing is not necessarily true. Most of the time, "seeing is false"

Finally got the byte offer. The 25-year-old inexperienced experience in software testing is written to you who are still confused

Tiflash compiler oriented automatic vectorization acceleration

Interviewer: with the for loop, why do you need foreach??

HBuilder左侧工具栏不见了

CTFHub-Web-密码口令-默认口令

【Redis】Set类型
Scala Foundation (3): Operators and Process Control
随机推荐
I'd like to ask you, where can I open an account in Zhongshan? Is it safe to open an account online?
大三下期末考試
Dialogue with opensea co creation Alex: we still only touch the tip of the iceberg of NFT capability | chain catcher
目标检测——ADAS实战
请问etf基金是否靠谱,安全吗
Flex application: realize two rows and five columns of data, self-adaptive
Blog publishing test 3
字符串输出
11 go Foundation: Interface
[從零開始學習FPGA編程-49]:視野篇 - 芯片是如何被設計出來的?
Wechat campaign auto like
Differences between web testing and app testing
【Redis】数据介绍 & 通用命令 & String类型
HashSet storing objects and how to not store the same objects
How to become a senior digital IC Design Engineer (4-3)
The 10 most commonly used gadgets for waterfall project management can be built and used freely
Why should the pointer be null after delete
I have summarized some experiences from the whole process of R & D platform splitting
[redis] sortedset type
Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!