当前位置:网站首页>Chapter 2 section 9: practice answers
Chapter 2 section 9: practice answers
2022-07-21 15:15:00 【Zhongyifeng Digital Technology Co., Ltd】
Python Basic introduction ( A full set of nanny level tutorials )
Chapter two
Section 9 : Practice the answer
Small exercise (*):
Change all people surnamed Zhang into Wang ,lst = [‘ Zhao Min ’, ‘ Zhang Shaogang ’, ‘ zhang wuji ’, ‘ Wu zetian ’, ‘ Ying Zheng ’, ‘ d ’].
lst = [' Zhao Min ', ' Zhang Shaogang ', ' zhang wuji ', ' Wu zetian ', ' Ying Zheng ', ' d ']
# for item in lst: # here , We can't see the index position of the element
for i in range(len(lst)): # len(lst) The length of the list -> You can get the list index directly for loop
item = lst[i] # item Still every item in the list
if item.startswith(" Zhang "):
# Zhang Shaogang
new_name = " king "+item[1:]
print(new_name)
# Put the new name back on the list ( Index is needed ?)
lst[i] = new_name # modify
print(lst)
summary :
Well understand the list index for loop
边栏推荐
- asp.net -GridView自带的删除行项超链接用法(DeleteButton)
- Kingbasees database administrator's Guide -- 18 database job scheduling
- 从表面看,元宇宙可能将从根本上改变人们的生产和生活方式
- Nacos cluster construction
- PLC的通信模式
- How to ensure data security while saving 30% disk space in tdsql PG version DB · insight
- 第二章第十一节:元组
- Networkx visualization graph how to get a graph based on time series
- Kingbasees SQL language reference manual of Jincang database (3.5 format model, 3.6 null value, 3.7 comments)
- 魑魅魍魉
猜你喜欢
随机推荐
LoRa基站覆盖范围
Functions of the machine room dynamic loop monitoring system and main functions of the dynamic loop monitoring system
mysql数据900W+从17s到300ms是怎么做到的?sql优化的魅力(荣耀典藏版)
SQL: SELECT t.`app_ code`, SUM(t.`success_num`) AS success_ num, SUM(t.`
浅聊一下 布隆过滤器
Kingbasees SQL language reference manual of Jincang database (3.5 format model, 3.6 null value, 3.7 comments)
从去IOE到CIPU,中国云计算要走出自己的路径
巧用RoaringBitMap处理海量数据内存diff问题
leetcode:42. Connect rainwater
C#与SAP接口对接
DAMA-第九章(文件与内容管理)
Rasterization comprehensive analysis
DAMA-第十二章(元数据管理)
[quick start tutorial 3] crazy shell · open source formation UAV - development environment construction
Lora技术助力冷链发展
第二章第十二节:set集合
Skillfully using roaringbitmap to deal with the memory diff problem of massive data
Implementation details of SAP e-commerce cloud Spartacus UI sitecontexturlparams
项目总结:文件管理系统
C#单例模式