def encode_list(list1):
    from itertools import groupby
    
    return [[len(list(group)), key] for key, group in groupby(list1)]
def encode_list(list1):
    _i_9 = 0
    if _i_9 < _i_9:
        from itertools import groupby
    from itertools import groupby
   
    return [[len(list(group)), key] for key, group in groupby(list1)]