当前位置:网站首页>字符串输出
字符串输出
2022-06-29 02:12:00 【长街395】
描述
用户输入一个字符串,在一行中输出其正向索引序号为偶数位置的字符。如用户输入:“hello”,程序运行后输出“hlo”。
输入格式
输入一个字符串
输出格式
输出一个字符串
示例 1
输入:hello
输出:hlo第一种用C语言的思维:
n=input()
t=len(n)
p=''
for i in range(0,t):
if(i%2==0):
p=p+n[i]
print(p)
第二种python极简:
str = input()
print(str[::2])
#print(a[0:len(a):2])也可以,上一行代码中省略起止位置,最后一个2是步长边栏推荐
- Studies of relative costs for development in different languages
- [redis] key hierarchy
- What is the Valentine's Day gift given by the operator to the product?
- KOA Quick Start
- SystemVerilog-结构体(一)
- [learn FPGA programming from scratch -50]: Vision - how are chips made? The thirteen steps of chip manufacturing.
- [learning notes] subsets and questions
- Server antivirus
- Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
- Introduction to super dongle scheme
猜你喜欢

【Redis】Hash类型

How to become a senior digital IC Design Engineer (4-2) script: file read / write operation realized by Verilog HDL code

瀑布型项目管理最常用的10个小工具,可以自由搭建使用

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

Understand flex layout in an article

How to choose source code encryption software

Server antivirus

HBuilder左侧工具栏不见了

The left toolbar of hbuilder is missing

I have summarized some experiences from the whole process of R & D platform splitting
随机推荐
okcc呼叫中心的计费方式哪个最好
[learn FPGA programming from scratch -49]: Vision - how is the chip designed?
什么叫股票线上开户?网上开户安全么?
跨境资讯站
How to become a senior digital IC Design Engineer (5-1) theory: clock technology, reset Technology
[redis] key hierarchy
为什么建议大家尽可能选择自研公司
Business system anti-virus
【Redis】初识 Redis
Adding, deleting, checking and modifying stack - dynamic memory
SystemVerilog-结构体(一)
How to become a senior digital IC Design Engineer (4-2) script: file read / write operation realized by Verilog HDL code
【Redis】Set类型
[learn FPGA programming from scratch -50]: Vision - how are chips made? The thirteen steps of chip manufacturing.
Redis data migration (III)
I'd like to ask you, where can I open an account in Zhongshan? Is it safe to open an account online?
Is it safe to contact the account manager online to open an account for stock speculation?
Use kubernetes resource lock to complete your own ha application
How to choose source code encryption software
Why is it recommended that you choose the self research company as much as possible