Python: Split a list into sub-lists based on index ranges

后端 未结 5 2086
感情败类
感情败类 2020-12-10 10:43

UPDATED:

In python, how do i split a list into sub-lists based on index ranges

e.g. original list:

list1 = [x,y,z,a,b,c,d,e,f,g]
5条回答
  •  死守一世寂寞
    2020-12-10 11:18

    list1=['x','y','z','a','b','c','d','e','f','g']
    find=raw_input("Enter string to be found")
    l=list1.index(find)
    list1a=[:l]
    list1b=[l:]
    

提交回复
热议问题