import random
practice_num = input("请输入练习题[1-9]:").strip()
if practice_num == '1':
# 1、
# 声明一个列表如:my_list = ["hello","python","itcast","hello"] ,
# 练习 对列表的 增删改查统计的操作
my_list = ["hello", "python", "itcast", "hello", "666"]
# 列表 末尾增加数据
my_list.append("666")
# 列表移出指定数据
my_list.remove("hello")
# 列表插入数据
my_list.insert(0, "zzzzzzzz")
# 列表 搜索指定数据的索引位置
my_list.index("itcast")
# 列表删除最后一个数据
print(my_list.pop())
# 列表查询数据
print(my_list[3])
# 列表统计数据
print(my_list.count("666"))
print("-" * 100)
# -----------------------------------
elif practice_num == "2":
# 2、
# 使用 for in 和 while 循环 二种方式 遍历列表["hello","python","itcast","world"]
my_list = ["hello", "python", "itcast", "hello", "666"]
for x in my_list
数据存储_代码练习题
最新推荐文章于 2023-05-10 23:40:14 发布