列表的改

#替换掉xiaozhang的值,修改为xiaoming
a=['xiaoxing','xiaoliu','xiaozhang','xiaohong','xiaoli','xiaozhao']
a[2]="xiaoming"
print(a)

输出结果:
['xiaoxing', 'xiaoliu', 'xiaoming', 'xiaohong', 'xiaoli', 'xiaozhao']

  




#替换掉xiaozhang,xiaohong的值,修改为b,c
a=['xiaoxing','xiaoliu','xiaozhang','xiaohong','xiaoli','xiaozhao']
a[2:4]=["b","c"]
print(a)

输出结果:
['xiaoxing', 'xiaoliu', 'b', 'c', 'xiaoli', 'xiaozhao']

  

上一篇:列表的删除


下一篇:列表的查