poem = ['杳','杳','寒','山','道']
print(poem[-2]) #列表索引负数
#切片
print(poem[1:])
print(poem[2:3:1])
print(poem[2:3])
print(poem[::-1]) #倒叙
print(poem[:]) #建立副本
#修改
print('修改前:',poem)
#1.直接通过索引
poem[0] = '啊'
poem[4] = 'he'
print('修改后:',poem)
#2.通过切片修改
print('切片修改前:',poem)
poem[0:2]=['好','和'] #使用新元素代替旧元素
poem[0:2]=['好','和','还'] #多的元素会插入列表
poem[0:0]=['哈哈']#给索引为0处插入元素
print('切片修改后:',poem)
#删除 del
poem1=['落','落','来','鉴','别']
del poem1[0:2] #删除索引位置的
print(poem1)
del poem1[::2] #删除步长为2
print(poem1)
#列表的遍历
#通过while循环遍历
lib=['luzi','hh','dou','xixi','huhu']
i=0
while i <len(lib):
print(lib[i])
i+=1
#通过for循环遍历
for s in lib:
print(s)
#元组 是无法改变的列表
my_tuple=(10,20,30,40)#创建元组 当元组非空时,括号可省略 既是my_tuple=10,20,30,40
a,b,c,d = my_tuple
#元组的解包 就是把元组中的值赋给变量(元组中值的格个数等于变量个数)
print(a)
print(b)
print(c)
print(d)
#*的使用
my_tuple1=(10,20,30,40)
a,*b,c=my_tuple1
print(a,*b,c)