I have
listName = [[0,1,2,15,16,17,2,3,4,6,8,9]]
My line of code
[list(g) for k, g in groupby(listName, key=lambda i,j=count(): i-next(j))]
splits listName into [[0,1,2],[15,16,17],[2,3,4],[6,8,9]] I want the split to occur only if the following number less than the previous one. those. I want my listName split into
[[0,1,2,15,16,17],[2,3,4,6,8,9]]
Thanks!:)
python lambda if-statement list-comprehension order
Mike issa
source share