Note that there are some explanatory texts on larger screens.

plurals
  1. POSplit the python list of list
    primarykey
    data
    text
    <p>Hello i am new to python i have a list of list,</p> <pre><code>data = [['shop_id', '=', 1], ['product_id', '=', 16], ['product_id', '=', 8], ['product_id', '=', 4], ['product_id', '=', 6], ['so', '=', 1],['so', '=', 2], ['state', '=', u'draft'] ] </code></pre> <p>and i wanted to a output like, </p> <pre><code>out_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']], ] </code></pre> <p>i have tried several method but can't find the solution.like</p> <pre><code>for domain in data: if domain[0] not in temp: final_dom.append(domain) print "final_dom :::",final_dom temp.append(domain[0]) else: print "adsada" final_dom.pop() final_dom.append(domain) print "final_dom :::",final_dom </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload