lst= [1,"2","3","2"]
print(lst.index('2'))
print(lst[2])
lst2=lst[0:2:1]
print(lst2)
lst2=lst[4::-1]
print((lst2))
print(1notinlst)
print(1inlst)
foriteminlst:
print(item)
lstAdd= [1,2,3,4,5]
print("未新增元素前的集合: ",lstAdd)
lstAdd.append(6) print("新增元素后的集合: ",lstAdd)
lstAdd.extend(lst) print("新增元素后的集合: ",lstAdd)
lstAdd.insert(7,2) print("新增元素后的集合: ",lstAdd)
lstAdd.remove(2) print("删除元素后的集合: ",lstAdd)
lstAdd.pop(2) print("删除元素后的集合: ",lstAdd)
lstAdd.clear() print("删除元素后的集合: ",lstAdd)
dellstAddlstUpdate= [1,2,3,4]
lstUpdate[2] =100print("修改元素后的集合: ",lstUpdate)
lstUpdate[1:2] = [66,66,66] print("修改元素后的集合: ",lstUpdate)
listSort= [1,3,2,6,5]
print("排序前的列表: ",listSort)
listSort.sort(reverse=True) print("排序后的列表: ",listSort)
newSortList=sorted(listSort,reverse=True) print("新的排序后的集合列表:",newSortList)
lst= [i*iforiinrange(1,10)]
print("生成后的列表: ",lst)