当前位置:网站首页>Example 040: Reverse List
Example 040: Reverse List
2022-08-04 01:39:00 【Lazy laughing】
Title: Output an array in reverse order.
Program Analysis: Swap positions in sequence, or call the reverse method directly.
Code:
Method one:
lis = [1, 10, 100, 1000, 10000, 100000]for i in range(int(len(lis) / 2)):lis[i], lis[len(lis) - 1 - i] = lis[len(lis) - 1 - i], lis[i]print(lis)Method Two:
lis = [1, 10, 100, 1000, 10000, 100000]print(lis[::-1])Method three:
lis.reverse()print(lis)Results:

"""Problems encountered during study and no one answered?The editor has created a QQ group for Python learning and communication, and you can enter the officially recommended group by scanning the code below.Looking for like-minded friends to help each other, there are also good video learning tutorials and PDF e-books in the group!↓↓↓↓↓↓"""边栏推荐
- nodejs+npm的安装与配置
- 如何通过API接口从淘宝(或天猫店)复制宝贝到拼多多接口代码对接教程
- Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
- esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
- idea中diagram使用
- nodejs+express实现数据库mysql的访问,并展示数据到页面上
- pygame 中的transform模块
- VR panorama shooting online exhibition hall, 3D panorama brings you an immersive experience
- 静态/动态代理模式
- Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
猜你喜欢

IDEA02:配置SQL Server2019数据库

nodejs+express实现数据库mysql的访问,并展示数据到页面上

LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization

MySQL回表指的是什么

Array_Sliding window | leecode brushing notes

Flask Framework Beginner-06-Add, Delete, Modify and Check the Database

数组_滑动窗口 | leecode刷题笔记

【虚拟户生态平台】虚拟化平台安装时遇到的坑

Use of lombok annotation @RequiredArgsConstructor

Installation and configuration of nodejs+npm
随机推荐
flask框架初学-06-对数据库的增删改查
【虚拟化生态平台】虚拟化平台搭建
- heavy OpenCV 】 【 mapping
实例041:类的方法与变量
this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
Electronics manufacturing enterprise deployment WMS what are the benefits of warehouse management system
LDO investigation
LDO investigation
typescript58 - generic classes
Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析
IDEA02:配置SQL Server2019数据库
实例035:设置输出颜色
有没有jdbc 链接优炫数据库文档及示例?
nodejs安装及环境配置
实例038:矩阵对角线之和
如何用C语言代码实现商品管理系统开发
GNSS[0]- Topic
【OpenCV】-重映射
GNSS【0】- 专题
Sticker Spelling - Memory Search / Shape Pressure DP