当前位置:网站首页>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!↓↓↓↓↓↓"""边栏推荐
- Quickly build a website with static files
- 浏览器存储
- nodejs安装及环境配置
- Array_Sliding window | leecode brushing notes
- Vant3 - click on the corresponding name name to jump to the next page corresponding to the location of the name of the TAB bar
- OpenCV如何实现Sobel边缘检测
- KunlunBase 1.0 is released!
- 一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
- 《The Google File System》新说
- 如何通过API接口从淘宝(或天猫店)复制宝贝到拼多多接口代码对接教程
猜你喜欢

实例036:算素数

lombok注解@RequiredArgsConstructor的使用

Quickly build a website with static files

nodejs+npm的安装与配置

阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践

Installation and configuration of nodejs+npm

特征值与特征向量

静态文件快速建站

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

appium软件自动化测试框架
随机推荐
浏览器存储
【OpenCV】-重映射
boot issue
静态文件快速建站
How to find the cause of Fiori Launchpad routing errors by single-step debugging
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
splice随机添加和删除的写法
工程制图平面投影练习
C # WPF equipment monitoring software (classic) - the next
redis中常见的问题(缓存穿透,缓存雪崩,缓存击穿,redis淘汰策略)
字符串变形
【虚拟户生态平台】虚拟化平台安装时遇到的坑
持续投入商品研发,叮咚买菜赢在了供应链投入上
什么是SVN(Subversion)?
Installation and configuration of nodejs+npm
vxe-table 从页面批量删除数据 (不动数据库里的数据)
C 学生管理系统_添加学生
2022年上半年各大厂Android面试题整理及答案解析(持续更新中......)
.NET Static Code Weaving - Rougamo Release 1.1.0
数组_滑动窗口 | leecode刷题笔记