Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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: OK 0.062 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'that?': 0.05; 'terms,': 0.09; 'tuple': 0.09; 'dec': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'structure.': 0.16; 'wrote:': 0.17; 'question.': 0.20; 'written': 0.20; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'received:209.85.210.46': 0.27; 'message- id:@mail.gmail.com': 0.27; 'writes:': 0.29; 'asking': 0.32; 'subject:List': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'item': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'group,': 0.60; 'john': 0.60; 'skip:n 10': 0.63; 'email addr:gmail.com': 0.63; 'more': 0.63; 'here': 0.65; 'dear': 0.66; 'as:': 0.75 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=m/jE4FQ/ROd3wusgd7cNfyvqiAOslSktXbt6aVsy3uw=; b=Q0A2voGbQXg3/NwiC9ytHDcvXuwKyH82sjInumQqcB+TScOPtn//jpxVVBG5yLn7oT ptA5hpy56KnyqWb6/DSLFBOnGUixrCuFPRe+LR9C6eg5symodOwpXls99N9NgMmt+UzP zSg1tPr7mwwTYRimbiL18C0ri5Ok6DkNlDimnprKJlsiwmmxR8VVwfR/jTK99v7JpCNV yVEWbQQPG+4dow7JHCWwddTgt5THhvAk1CQiRiShIWwYknbYiVuhbrY9NML8Trpdu/x2 EUjDh/hvJNHoFF27ac/NxZ6Pqtr29TbMXTX4CMKjJYrA9Hi57tZ8u5B181emHY+IRlY8 TtMw== MIME-Version: 1.0 In-Reply-To: References: <6049bc85-6f8e-429b-a855-ecef47a9d28e@googlegroups.com> Date: Tue, 4 Dec 2012 07:17:05 +1100 Subject: Re: Conversion of List of Tuples From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354565829 news.xs4all.nl 6952 [2001:888:2000:d::a6]:43833 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34188 On Tue, Dec 4, 2012 at 7:04 AM, John Gordon wrote: > In <6049bc85-6f8e-429b-a855-ecef47a9d28e@googlegroups.com> subhabangalore@gmail.com writes: > >> Dear Group, > >> I have a tuple of list as, > >> tup_list=[(1,2), (3,4)] >> Now if I want to covert as a simple list, > >> list=[1,2,3,4] > >> how may I do that? > > new_list = [] > > for t in tup_list: > for item in t: > new_list.append(item) Which can be written more succintly as: new_list = [] for t in tup_list: new_list.extend(t) In more general terms, what you're looking to do here is *flatten* your structure. Not sure if that would have helped in the web search that you doubtless did before asking this question. :) ChrisA