On 10/08/2012 11:15 PM, Prasad, Ramit wrote: > Agon Hajdari wrote: >> Sent: Monday, October 08, 2012 3:12 PM >> To: python-list@python.org >> Subject: Re: Insert item before each element of a list >> >> On 10/08/2012 09:45 PM, Chris Kaynor wrote: >>> [('insertme', i) for i in x] >> >> This is not enough, you have to merge it afterwards. > > Why do you say that? It seems to work just fine for me. > >>>> x > [0, 1, 2, 3, 4] >>>> [('insertme', i) for i in x] > [('insertme', 0), ('insertme', 1), ('insertme', 2), ('insertme', 3), > ('insertme', 4)] > >> >> y = [item for tup in y for item in tup] >> > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. >
I think he wanted to have a 'plain' list a = [0, 1, 0, 2, 0, 3] and not a = [(0, 1), (0, 2), (0, 3)] -- http://mail.python.org/mailman/listinfo/python-list