下一章 上一章 目录 设置
10、2022.04.08 ...
-
python
3-10尝试使用各个函数存储列表:山岳、河流、国家、城市、语言
创建列表
使用本章函数处理列表
3.4使用列表避免索引错误
error 1:
motorcycles=【*honda*,*yamaha*,*suzuki*】print(motorcycles【3】)
error 2:
motorcycles=【 】
print(motorcycle【-1】)
3-11 有意引发错误
3.5 小结
1什么是列表
2使用其中的元素
3定义列表
4增删元素
5永久性排序
6临时性排序
7确定长度
8避免错误
items=【‘tang’,‘yuan’,‘qing’】
message=“The first three items in the list are:”
for item in items【0:2】:
print(message)
print(item.title())
The first three items in the list are:
Tang
Yuan
Qing