Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: UNSURE 0.332 X-Spam-Level: *** X-Spam-Evidence: '*H*': 0.42; '*S*': 0.08; 'tmp': 0.09; 'clear.': 0.16; 'subject:make': 0.16; 'elements': 0.16; 'thanks.': 0.20; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'twitter:': 0.31; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'new': 0.61; 'more': 0.64; 'different': 0.65; 'regards.': 0.65; 'here': 0.66; 'beautiful': 0.68; 'skip:r 40': 0.68; 'charset:gb2312': 0.80; 'skip:/ 30': 0.84; 'url:tt': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=wD0uzG2Q8dm7F6pK0gQgGABgd7Kilvql5wvAyuuEu4w=; b=LVeSenpMhuhdMsPsbHrGgDXEQ67V+O30i5zwNIdAJ3HWr4hPe9hPVkCHhhf9OMNZ5B N9cose5lplfLb/ZYeYJSbDJnub4bflfNXuApLI13AJT9Fdd3zZDxJo50Ryd8lPGjDuns CfM0Z2k89IeN4kHOiDbFjBs7gcz9LVX80uCR1u0t8FKyRacKz6ZQ7eAxqLPtLVSVnWEi XeCkzF1gjFEVbO2v4nnZGvU6YtYEd6F+LGd9oDiKlHsCzGEEca9Sa/0mow7BBjXAjoX2 MMUm+PTYJtpQEZcumziy4SXU/n6sFfx8g3+C3SYuq+eZ8sDol1O+rwvIUr0Y0Xd1jDlO +6JA== MIME-Version: 1.0 X-Received: by 10.59.0.2 with SMTP id au2mr653689ved.83.1375865448705; Wed, 07 Aug 2013 01:50:48 -0700 (PDT) Date: Wed, 7 Aug 2013 16:50:48 +0800 Subject: make elements of a list twice or more. From: liuerfire Wang To: python-list@python.org Content-Type: multipart/alternative; boundary=047d7bd750b254358504e357a3b9 X-Mailman-Approved-At: Wed, 07 Aug 2013 18:43:40 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375893821 news.xs4all.nl 15867 [2001:888:2000:d::a6]:46228 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52140 --047d7bd750b254358504e357a3b9 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable Sorry for the title which didn't make clear. Here is a list x =3D [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]. I know we can do like that: tmp =3D [] for i in x: tmp.append(i) tmp.append(i) However, I wander is there a more beautiful way to do it, like [i for i in x]? Thanks. --=20 Best regards. /********************************** google+: +liuerfire twitter: @liuerfire =B5=B0=CC=DB=B2=BB=B5=B0=CC=DB=B5=C4=B6=BC=BF=C9=D2=D4=CA=D4=D7=C5=B5=E3=D2= =BB=CF=C2~^_^~ ***********************************/ --047d7bd750b254358504e357a3b9 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: quoted-printable
Sorry for the title which didn't make clear.

<= /div>
Here is a list x =3D [b, a, c] (a, b, c are elements of x. Each o= f them are different type).  Now I wanna generate a new list as [b, b,= a, a, c, c].

I know we can do like that:
tmp =3D []
for i i= n x:
    tmp.append(i)
    tmp.appe= nd(i)

However, I wander is there a more beautiful way to = do it, like [i for i in x]?

Thanks.

=

--
Best regards.
/************= **********************
--047d7bd750b254358504e357a3b9--