Question: 
Write a function to reflect the run-length encoding from a list.


Model's Code:
def encode_list(input_list):
    if not input_list:
        return []
    
    encoded = []
    count = 1
    for i in range(1, len(input_list)):
        if input_list[i] == input_list[i - 1]:
            count += 1
        else:
            encoded.append([count, input_list[i - 1]])
            count = 1
    encoded.append([count, input_list[-1]])
    
    return encoded



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


Asserts:
assert encode_list([1,1,2,3,4,4.3,5,1])==[[2, 1], [1, 2], [1, 3], [1, 4], [1, 4.3], [1, 5], [1, 1]]
assert encode_list('automatically')==[[1, 'a'], [1, 'u'], [1, 't'], [1, 'o'], [1, 'm'], [1, 'a'], [1, 't'], [1, 'i'], [1, 'c'], [1, 'a'], [2, 'l'], [1, 'y']]
assert encode_list('python')==[[1, 'p'], [1, 'y'], [1, 't'], [1, 'h'], [1, 'o'], [1, 'n']]


Tests:
Test 1 of 3: PASS
Test 2 of 3: PASS
Test 3 of 3: PASS

Test 157 of 974: 114/157 (72.61146496815286%): success