def encode_list(list1):
    from itertools import groupby
    
    return [[len(list(group)), key] for key, group in groupby(list1)]
def encode_list(list1):
    from itertools import groupby
   
    return [[len(list(group)), Pvk] for Pvk, group in groupby(list1)]