当前位置:网站首页>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)
边栏推荐
- How to become a senior digital IC Design Engineer (1-1) Verilog coding Grammar: Introduction
- Which brokerage is safer and more convenient to open a stock account for big smart phones?
- What is stock online account opening? Is it safe to open an account online?
- [redis] hash type
- 如何成为一名高级数字 IC 设计工程师(4-3)脚本篇:C 语言实现的文件读写操作
- How to become a senior digital IC Design Engineer (6-6) digital IC Verification: system level simulation
- Digital IC design, FPGA design written examination questions, answers and analysis of autumn move (1) 2022 Ziguang zhanrui (Part 1)
- How to become a senior digital IC Design Engineer (6-7) digital IC Verification: debug skills
- 如何成为一名高级数字 IC 设计工程师(6-7)数字 IC 验证篇:DEBUG 技巧
- chrome浏览器关闭更新弹窗
猜你喜欢

Use code binding DataGridView control to display tables in program interface

How to use project Gantt chart to make project report
Fundamentals of scala (3): operators and process control

Koa quick start

Chrome browser close update Popup

SystemVerilog-结构体(一)

"The first share of endoscope" broke into IPO two times. Last year, it lost 500million yuan. The commercialization of core products is still in doubt | IPO Express

I have summarized some experiences from the whole process of R & D platform splitting

Oculusrifts and unity UI interaction (1) - Overview

What is the dry goods microservice architecture? What are the advantages and disadvantages?
随机推荐
Dialogue with opensea co creation Alex: we still only touch the tip of the iceberg of NFT capability | chain catcher
How to become a senior digital IC Design Engineer (5-1) theory: clock technology, reset Technology
[从零开始学习FPGA编程-49]:视野篇 - 芯片是如何被设计出来的?
[redis] sortedset type
Is there any risk in opening an account for Dongfang fortune stock? Is it safe for Dongfang fortune to open an account
QT basics tutorial: data types and containers
Understand flex layout in an article
大智慧手机股票开户哪个券商更安全更方便?
"The first share of endoscope" broke into IPO two times. Last year, it lost 500million yuan. The commercialization of core products is still in doubt | IPO Express
[network communication learning notes] socket IO setup and deployment
How to become a senior digital IC Design Engineer (6-4) digital IC Verification: test point decomposition
11-Go基础:接口
【Redis】Hash类型
What is the Valentine's Day gift given by the operator to the product?
Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
学习太极创客 — MQTT 第二章(九)本章测试
计算矩形面积
为什么要在网站上安装SSL证书?
目标检测——ADAS实战
【学习笔记】子集和问题