Slice a list every time it contains a list of items

hello, it looks amazing many thanks, but it is not doing what I was expecting. The original list is flatten and the sublists are created each time the key list is found on the list, so first item of the sublists must be a key of the list but it is not happening here

Ok I understood the opposite (keys at the ends)

import sys

def r_split(lst):
    out_ = []
    for i in lst:
        if i in s_values and out_:
            yield out_
            out_ = [i]
        else:
            out_.append(i)
    if out_:
        yield out_
        
input_lst = IN[0]
s_values = IN[1]

OUT = list(r_split(input_lst))
1 Like

amazing to see how same thing can me done in multiple different ways in python, very valuable responses here, much appreciated, it looks simple though! at the beginning I was trying to get sample ideas from this website, sometimes similar questions are responded https://stackoverflow.com/