Merge some list items in a Python List

后端 未结 5 2062
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 01:42

Say I have a list like this:

[a, b, c, d, e, f, g]

How do modify that list so that it looks like this?

[a, b, c, def, g]
         


        
5条回答
  •  春和景丽
    2020-12-24 02:02

    just a variation

    alist=["a", "b", "c", "d", "e", 0, "g"]
    alist[3:6] = [''.join(map(str,alist[3:6]))]
    print alist
    

提交回复
热议问题