Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Vito De Tullio Newsgroups: comp.lang.python Subject: Re: repeat items in a list Date: Tue, 29 Mar 2016 23:25:36 +0200 Lines: 12 Message-ID: References: <8935d5dc-5e62-4fa8-8e8f-bd5b1787ee9f@googlegroups.com> <29bb9c16-eef4-4c00-9e41-ce8419405c29@googlegroups.com> <1459173882.380114.561434386.096F166A@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de M7DVPQ3HxMh6u+K2jGzcWgvNTFZtlDElJAq2bSQ08Obw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '[])': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; "'a',": 0.16; "'b',": 0.16; "'c',": 0.16; "['a',": 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'header :User-Agent:1': 0.26; 'subject:list': 0.26; 'header:X-Complaints- To:1': 0.26; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'received:2': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 2.193.37.81 User-Agent: KNode/4.14.10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:106002 Random832 wrote: > How do you turn ['a', 'c', 'b'] into ['a', 'a', 'a', 'c', 'c', 'c', 'b', > 'b', 'b']? >>> sum([[e]*3 for e in ['a', 'c', 'b']], []) ['a', 'a', 'a', 'c', 'c', 'c', 'b', 'b', 'b'] -- By ZeD