当前位置:网站首页>问题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]
边栏推荐
- 日志级别 和 打印log注意
- IIR filter and FIR filter
- errno错误码及含义(中文)
- [C language] General method of expression evaluation
- 【AUTOSAR-RTE】-4-Port and Interface and Data Type
- (八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
- Day32 LeetCode
- A brief introduction to the showDatePicker method of the basic components of Flutter
- BUG definition of SonarQube
- "A daily practice, happy water problem" 1331. Array serial number conversion
猜你喜欢
(八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
Component pass value provide/inject
[Dynamic programming] Maximum sum of consecutive subarrays
「 每日一练,快乐水题 」1331. 数组序号转换
A brief introduction to the CheckboxListTile component of the basic components of Flutter
大小端模式
Mysql 45 study notes (23) How does MYSQL ensure that data is not lost
[Compilation principle] Lexical analysis program design principle and implementation
A brief introduction to the showDatePicker method of the basic components of Flutter
What skills do I need to learn to move from manual testing to automated testing?
随机推荐
(六)枚举、注解
[Compilation principle] Lexical analysis program design principle and implementation
C language from entry to such as soil, the data store
安全20220715
Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
No qualifying bean of type question
log level and print log note
What skills do I need to learn to move from manual testing to automated testing?
No qualifying bean of type 问题
Understanding and Using Unity2D Custom Scriptable Tiles (4) - Start to build a custom tile based on the Tile class (below)
IIR filter and FIR filter
浅识Flutter 基本组件之showDatePicker方法
[C language] Three-pointed chess (classic solution + list diagram)
Day32 LeetCode
Pytest e-commerce project combat (on)
Key Technologies of Interface Testing
els 方块向右移
日志级别 和 打印log注意
Component pass value provide/inject
Postgresql 15 source code analysis (5) - pg_control