I have some input data format, its like a tree. and contains list of list of list. the input is like
in_put = [[['shop_id', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 16]],
[['shop_id', '=', 1],['product_id', '=', 8]],
[['shop_id', '=', 1],['product_id', '=', 4]],
[['shop_id', '=', 1],['product_id', '=', 6]],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 2],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 2],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 2],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 2],['state', '=', u'draft']],
]
and i wanted to arrange the data in below format.
output = [
[['shop_id', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 16]],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 16],['so', '=', 2],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 8]],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 8],['so', '=', 2],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 4]],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 4],['so', '=', 2],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 6]],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 1]],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 2]],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 1],['state', '=', u'draft']],
[['shop_id', '=', 1],['product_id', '=', 6],['so', '=', 2],['state', '=', u'draft']],
]
How do i achieve such data arrangement.Is there any short method available in python,