Python 3.X iteration through lists : Looking for some help iterating through lists. I have the following code:

    import numpy as np
    import random
    
    dic = {2:[],4:[]}
    lis = []
    
    for number in range(0,10):
        lis.append(random.sample(range(0,9),8))
        lis[-1].append(random.randint(2,4))
    
    for i in lis:
        dic[i[-1]].append(i[:-1])

I am trying to place the randomized items, appended with a 2 or a 4 at the end, into a predefined dictionary called dir. Thanks in advance - this is my first question so I apologize for any redundancy. 