make elements of a list twice or more.

alex23 wuwei23 at gmail.com
Mon Aug 19 23:42:27 EDT 2013


On 7/08/2013 6:50 PM, liuerfire Wang wrote:
> Here is a list x = [b, a, c] (a, b, c are elements of x. Each of them 
> are different type).  Now I wanna generate a new list as [b, b, a, a, c, c].

from itertools import chain

new_list = list(chain.from_iterable(zip(x,x)))



More information about the Python-list mailing list