当前位置:网站首页>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!↓↓↓↓↓↓"""边栏推荐
- Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
- How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
- C 学生管理系统_分析
- The 600MHz band is here, will it be the new golden band?
- Variable string
- [store mall project 01] environment preparation and testing
- 安全至上:落地DevSecOps最佳实践你不得不知道的工具
- nodejs installation and environment configuration
- 工程制图复习题
- Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
猜你喜欢

Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment

字符串变形

- heavy OpenCV 】 【 mapping

lombok注解@RequiredArgsConstructor的使用

typescript57 - Array generic interface

js中常用的几种遍历处理数据的方法梳理

安全至上:落地DevSecOps最佳实践你不得不知道的工具

Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment

螺旋矩阵_数组 | leecode刷题笔记

【OpenCV】-重映射
随机推荐
GNSS文章汇总
Parquet encoding
VR panorama shooting online exhibition hall, 3D panorama brings you an immersive experience
Observability:你所需要知道的关于 Syslog 的一些知识
Multithreading JUC Learning Chapter 1 Steps to Create Multithreading
哎,又跟HR在小群吵了一架!
nodejs installation and environment configuration
typescript52 - simplify generic function calls
pygame 中的transform模块
实例041:类的方法与变量
【Untitled】
esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
5. Scrapy middleware & distributed crawler
持续投入商品研发,叮咚买菜赢在了供应链投入上
C # WPF equipment monitoring software (classic) - the next
即席查询——Presto
Promise 解决阻塞式同步,将异步变为同步
thinkphp 常用技巧
Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)
typescript55 - generic constraints