I've been through itertools inside and out and I cannot figure out how to do the following. I want to take a list.
x = [1,2,3,4,5,6,7,8]
and I want to get a new list:
y = [[1],[1,2],[1,2,3],.......[2],[2,3],[2,3,4].....[8]]
I need a list of all slices, but not combinations or permutations.
x = list(zip(x[::2], x[1::2]))
is close, but doesn't do exactly what I'm hoping
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…