当前位置:网站首页>Section 10 of Chapter 2: supplementary knowledge points of the list
Section 10 of Chapter 2: supplementary knowledge points of the list
2022-07-21 15:15:00 【Zhongyifeng Digital Technology Co., Ltd】
Python Basic introduction ( A full set of nanny level tutorials )
Chapter two
Section 10 : Supplementary knowledge points of the list
Other operations of the list ( Add )
Sort
The list will be saved in the order you store it
sort Sort the list in ascending order
reverse: Flip
lst = [1, 2, 3, " Gentiana ", " Wu Da Long "] # The list will be saved in the order you store it
print(lst)
lst = [222, 444, 123, 43, 123,43243, 111]
lst.sort() # Sort the list in ascending order
lst.sort(reverse=True) # reverse: Flip
print(lst)
Nesting of lists
lst = ["abc", "def", [" Ha ha Da ", " Mom ", " Bitter ridge tile ", [" coke ", "scrapy", 123]], 'aed', "qpr"]
print(lst[2][3][1])
lst[2][3][1] = lst[2][3][1].upper()
print(lst)
Circular deletion of list
Prepare a temporary list , Be responsible for storing the content to be deleted , Record the contents to be deleted , Delete from the original list .
lst = [' Zhao Min ', ' Zhang Shaogang ', ' zhang wuji ', ' Wu zetian ', ' Ying Zheng ', ' d ']
temp = [] # Prepare a temporary list , Be responsible for storing the content to be deleted
for item in lst:
if item.startswith(" Zhang "):
temp.append(item) # Record the contents to be deleted
# lst.remove(item) # Yes bug
for item in temp:
lst.remove(item) # Delete from the original list
print(lst)
summary :
sort Sort the list in ascending order ,reverse Flip ,
Pay attention to , Prepare a temporary list , Be responsible for storing the content to be deleted , Record the contents to be deleted , Delete from the original list .
边栏推荐
- Opportunities and challenges coexist for financial enterprises to go to sea in emerging markets, advance AI ensures its safety and compliance development
- Functions of the machine room dynamic loop monitoring system and main functions of the dynamic loop monitoring system
- Multiplier technology cloud management and control platform adapts to Alibaba cloud polardb, and jointly promotes the prosperity of cloud native database ecosystem
- [daily question] 1260 2D mesh migration
- Kingbasees database administrator's Guide -- 15.1 Manage views
- DAMA-第六章(数据存储与操作)
- HVV蓝队之入侵排查
- 【LeetCode】29、 两数相除
- 巧用RoaringBitMap处理海量数据内存diff问题
- leetcode:689. Maximum sum of three non overlapping subarrays
猜你喜欢
C语言详解系列——goto语句的讲解和循环语句的简单练习题
openGauss内核分析:查询重写
leetcode:407. Connected to rainwater II
数据仓库和数据中台的关系
Nacos cluster construction
SQL: SELECT t.`app_ code`, SUM(t.`success_num`) AS success_ num, SUM(t.`
leetcode:689. Maximum sum of three non overlapping subarrays
asp.net -编辑超链接事件
Mysql的主键UUID、自增ID、雪花算法到底该怎么选择?(荣耀典藏版)
Web3流量聚合平臺Starfish OS,詮釋真正商業的“P2E”生態
随机推荐
Web3流量聚合平台Starfish OS,给玩家元宇宙新范式体验
[leetcode] 29. Divide two numbers
NFS共享存储服务
巧用RoaringBitMap处理海量数据内存diff问题
.NET Core 加载程序集AssemblyLoadContext
C#与SAP接口对接
【二叉树】分裂二叉树的最大乘积
Yunna Xianning communication machine room dynamic loop monitoring system, telecom dynamic loop monitoring system
DAMA-第五章(数据建模与设计)
金融企业出海新兴市场机遇与挑战并存,ADVANCE.AI保障其安全合规发展
How many bytes do double, float and long occupy?
第二章 第四节:替换和切割
[public class preview]: cloud video conference system privatization practice
Idea 2021 automatically generates serialVersionUID
Okaleido tiger NFT即将登录Binance NFT平台,后市持续看好
【LeetCode】29、 两数相除
Research Report - visible light communication and visible light positioning
DAMA-第十二章(元数据管理)
国债逆回购安全吗 怎么卖出去
发票自动处理——摆脱纸张和数据输入的束缚,自动化工作流程和异常处理,大幅缩短审核准备时间