当前位置:网站首页>列表推导式
列表推导式
2022-07-25 07:03:00 【qq_42307546】
""" 将liitst01所有的元素,都增加1以后存入list02中 """
list01 =[5,4,3,7,8,0]
list02=[]
for item in list01:
list02.append(item+1)
#列表推导式
list02=[item+1 for item in list01]
""" 将liitst01大于元素,都增加1以后存入list02中 """
list01 =[5,4,3,7,8,0]
list02=[]
for item in list01:
if item >10:
list02.append(item+1)
#列表推导式
list02=[item+1 for item in list01 if item>10]
list01 = [item ** 2 for item in range(1, 11)]
list02 = [item for item in list01 if item % 2 != 0]
list03 = [item for item in list01 if item % 2 == 0]
list04 = [item+1 for item in list01 if item % 2 == 0 and item>5]
print(list04)
边栏推荐
- Special analysis of data security construction in banking industry
- ArgoCD 用户管理、RBAC 控制、脚本登录、App 同步
- 流量对于元宇宙来讲并不是最重要的,能否真正给传统的生活方式和生产方式带来改变,才是最重要的
- [C language] document processing and operation
- 百度希壤首场元宇宙拍卖落槌,陈丹青六幅版画作品全部成交!
- Introduction to bridging mode and sharing mode
- 不只是日志收集,项目监控工具Sentry的安装、配置、使用
- Health clock in daily reminder tired? Then let automation help you -- hiflow, application connection automation assistant
- [C language] program environment and preprocessing
- 解密NumPy求解梯度的一个关键难点
猜你喜欢

Can communication test based on STM32: turn the globe

Detailed explanation of the difference, working principle and basic structure between NMOS and PMOS

Baidu xirang's first yuan universe auction ended, and Chen Danqing's six printmaking works were all sold!

Install, configure, and use the metroframework in the C WinForms application

Insight into mobile application operation growth in 2022 white paper: the way to "break the situation" in the era of diminishing traffic dividends

机器人工程-教学品质-如何判定

Rambus announces ddr5 memory interface chip portfolio for data centers and PCs

Robot engineering - teaching quality - how to judge

【C】 Program environment and pretreatment

Recycleview realizes horizontal sliding of overlapping items
随机推荐
【每日一题】剑指 Offer II 115. 重建序列
C#控件开源库:MetroFramework的下载
Thread 类的基本用法
Baidu xirang's first yuan universe auction ended, and Chen Danqing's six printmaking works were all sold!
%d,%s,%c,%x
Developers must read: 2022 mobile application operation growth insight white paper
Wei Lai: what is the difference between multithreaded join and detach?
【知识总结】分块和值域分块
Clear wechat applet and wechat H5 cache
杜教筛
Over adapter mode
【电脑讲解】去电脑维修店修电脑需要注意什么?
Analysis of the calling principle of Changan chain solid smart contract
CTF Crypto---RSA KCS1_OAEP模式
Rust标准库-实现一个TCP服务、Rust使用套接字
Leetcode46 Full Permutation (Introduction to backtracking)
C control open source library: download of metroframework
100 GIS practical application cases (seventeen) - making 3D map based on DEM
微信小程序switchTab传参以及接收参数
The ultimate difference between MVC and three-tier architecture