How i can get items of local scope in nested list? : So i am try to find  consecutive and i wrote a script :

    a = [1, 1, 1, 2, 3, 2,2,2, 1, 2, 3, 4, 1, 1, 1,5,5,5]
    
    
    
    new_list_1=[]
    new_list_2=[]
    def hello(x):
    
        for j,i in enumerate(x):
    
    
    
            try:
                if x[j] == x[j + 1] or x[j]==x[j-1]:
                    new_list_1.append((i, j))
    
                else:
                    new_list_2.append((i, j))
    
    
            except IndexError:
    
                if x[j]==x[j-1]:
                    new_list_1.append((i, j))
    
    
    
    
    
    
    print(hello(a))
    
    print(new_list_1)

its returning :

    [(1, 0), (1, 1), (1, 2), (2, 5), (2, 6), (2, 7), (1, 12), (1, 13), (1, 14), (5, 15), (5, 16), (5, 17)]

But i want something like this:

expected output:

    [[(1, 0), (1, 1), (1, 2)], [(2, 5), (2, 6), (2, 7)], [(1, 12), (1, 13), (1, 14)], [(5, 15), (5, 16), (5, 17)]]

I don't want to use any external module like itertools chain or groupby , How can i achieve this ?