How to find all ways from up to down in list use python
Question: Python v.3.2.3:  
Need to find all path in this `list[]`, but go down accept only `(↓, ↓+right)`
. In finish need create list of `list(all paths)` from `up([0][0])` to
`down([6][x])`.

Example(list):

    
    
    [[30], [27, 84], [25, 33, 11], [31, 54, 79, 95], [98, 27, 61, 90, 52], 
     [12, 72, 29, 64, 27, 81], [90, 23, 24, 73, 69, 63, 47]]
    

Example `list([all paths][.][.][.][.][.][.][.])`:

    
    
     [[30, 27, 25, 31, 98, 12, 90], [30, 27, 25, 31, 98, 12, 23].............]
    

Code:

    
    
    from random import randint
    
    
    col_str=randint(6,10)
    
    '''create pyramid 2d array'''
    def newpyramid():
        masiv=[]
        index = 0
    
        for i in range(0,col_str):
    
            masiv.append([])
            index+=1
            #print(index)
            for j in range(0,index):
                masiv[i].append(randint(10,99))
        return masiv
    
    b=newpyramid()  
    print(b)
    
    '''function that find nodes (↓, ↓+right) '''
    def get_list_subnodes(depth, width):
    
        try:
            pyramid[depth+1]
        except IndexError:
            return False
        else:
            subnodes = []
            subnodes1 = []
            subnodes2 = []
            subnodes1.append(depth + 1)
            subnodes1.append(width)
            subnodes2.append(depth + 1)
            subnodes2.append(width + 1)
            subnodes.append(subnodes1)
            subnodes.append(subnodes2)
    
            return subnodes
    
    
    '''function go by 2 nodes from get_list_subnodes'''
    def go_pyramid(depth, width, way):
    
        way1.append(pyramid[depth][width])
        way2.append(pyramid[depth][width]) 
    
        #print(depth)
        list_subnodes = get_list_subnodes(depth, width)
    
        print(list_subnodes)
        if list_subnodes==False:
            ways.append(way1)
            ways.append(way2)
            return
    
        go_pyramid(list_subnodes[1][0], list_subnodes[1][1], way1)
        go_pyramid(list_subnodes[0][0], list_subnodes[0][1], way2)
    
    ways=[]
    go_pyramid(0, 0, way1)
    print(ways)
    


Answer: What you are trying to achieve is called Cartesian product of a sequence of
lists. There is already a library support in python
[itertools.product](http://docs.python.org/2/library/itertools.html#itertools.product).

    
    
    lst=[[30], [27, 84], [25, 33, 11], [31, 54, 79, 95], [98, 27, 61, 90, 52], 
     [12, 72, 29, 64, 27, 81], [90, 23, 24, 73, 69, 63, 47]]
    from itertools import product
    result = map(list, product(*lst))
    

