I have a list of lists, and for each list within a list, I want to split it into two lists such that each list's length has a max of 30, otherwise I discard the remainder that can't be fit into 30 and aren't approximately close to 30.
For example: List 1 has a length of 64 -> split it into two lists of 30, 30, and discard the remaining 4.
or List 2 has length of 41, I generate a new list of 30 and discard the 11.
or List 3 has length of 58, I generate two lists of 30 and 28.
I'm using a list splitting function I found: https://stackoverflow.com/a/1751478/2027556
right now my code is something like:
new_list = []
for list_ in cluster:
    if len(list_) < 31 and len(list_) > 24:
       new_list.append(list_)
    elif len(list_) >= 31:
       chunks_list = chunks(list_, 30)
       for item in chunks_list:
          if len(item) > 25:
             new_list.append(item)
as you can see right now I'm just making a new list and going through the old one, but I think there's a more elegant pythonic solution maybe using list comprehension?
 
     
     
     
     
     
     
     
     
    