当前位置:网站首页>问题7:列表的拼接
问题7:列表的拼接
2022-07-31 03:42:00 【理不尽的神之手】
# 方式1:使用+
numbers = []
even = [number for number in range(11) if not number % 2]
odd = [number for number in range(11) if number % 2]
numbers += even + odd
print(numbers)
# [0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]
# 方式2:使用list_name.extend(list1)
numbers = []
rights = [1, 3, 5, 7, 8, 10, 12]
numbers.extend(rights)
print(numbers)
# [1, 3, 5, 7, 8, 10, 12]
边栏推荐
- [C language] General method of expression evaluation
- 从滴滴罚款后数据治理思考
- (六)枚举、注解
- What skills do I need to learn to move from manual testing to automated testing?
- beforeDestroy与destroyed的使用
- Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
- Use of QML
- No qualifying bean of type 问题
- 数据库实现分布式锁
- web容器及IIS --- 中间件渗透方法1
猜你喜欢

endian mode
![[C language] General method of base conversion](/img/28/954af5f47a79ff02d3cc0792ac8586.jpg)
[C language] General method of base conversion

The application and practice of mid-to-platform brand advertising platform

IIR filter and FIR filter

Mysql 45 study notes (twenty-four) MYSQL master-slave consistency

【论文阅读】Mastering the game of Go with deep neural networks and tree search

5. How does the SAP ABAP OData service support the $filter operation

LeetCode simple problem to find the subsequence of length K with the largest sum
![[Swift]自定义点击APP图标弹出的快捷方式](/img/d4/84b237995fc3d3700916eb57f6670d.png)
[Swift]自定义点击APP图标弹出的快捷方式

IDEA常用快捷键与插件
随机推荐
Implementation of a sequence table
IIR filter and FIR filter
组件传值 provide/inject
PMP WeChat group daily exercises
Pytest电商项目实战(上)
自己的一些思考
[Compilation principle] Design principle and implementation of recursive descent parsing
Postgresql 15 source code analysis (5) - pg_control
Safety 20220709
Redis 使用LIST做最新评论缓存
顺序表的实现
ClickHouse:设置远程连接
Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
【论文阅读】Mastering the game of Go with deep neural networks and tree search
(tree) Last Common Ancestor (LCA)
Automation strategies for legacy systems
els block to the left to move the conditional judgment
Annotation usage meaning
Safety 20220715
TCP和UDP详解