I have a list of integers, in which some are consecutive numbers.
What I have:
myIntList = [21,22,23,24,0,1,2,3,0,1,2,3,4,5,6,7]
etc...
What I want:
MyNewIntList = [[21,22,23,24],[0,1,2,3],[0,1,2,3,4,5,6,7]]
I want to be able to split this list by the element 0, i.e when looping, if the element is 0, to split the list into separate lists.
Then, after splitting myIntList
whatever number of times (based on the recurrences of finding the element 0), I want to append each 'split' or group of consecutive integers into a list within a list.
Also would I be able to do the same sort of thing with a 'list of strings' instead of integers? (Split the main string list into smaller lists based on a reoccurring element)
EDIT:
How would I go about splitting the list by consecutive numbers? There's a part in my list where it jumps from 322 to 51, there is no 0 in between. I want to split:
[[...319,320,321,322,51,52,53...]]
into
[[...319,320,321,322],[51,52,53...]]
basically, how do I split elements in a list by consecutive numbers?
Posted here: Split list of lists (integers) by consecutive order into separate lists