Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '[1,': 0.09; 'to:addr:python.list': 0.09; 'to:addr:tim.thechases.com': 0.09; 'to:name:tim chase': 0.09; 'cc:addr:python-list': 0.10; '-tkc': 0.16; '12]': 0.16; 'wrote:': 0.17; 'tim': 0.18; '>>>': 0.18; 'simpler': 0.22; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'cc:addr:gmail.com': 0.27; 'message-id:@mail.gmail.com': 0.27; '>>>>': 0.29; 'chase': 0.29; 'print': 0.32; '11,': 0.33; 'shorter': 0.33; 'subject:List': 0.33; 'version:': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'little': 0.39; 'header:Received:5': 0.40; 'helps': 0.63; 'email addr:gmail.com': 0.63; 'subject:For': 0.75 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=wCEMWvg+2xy6DrYc4rw7p8YGGCc8DKYhJshM8qxrZ6Q=; b=Ur9QjmkvWoXsylaMx1s8JtZhMIy9QByWEjiOGimgoTOsdhVRkXUQTp25t+B+4UiTqY Jo0VJgM0BQtlaUcEeIDyrCJ1rUqORRjy/5pmIfjIMjkQHy0yj9JyooWjVV5R3bK8mNOg xEUDX3sOctOzjhV8ypG3RxDzzh1Fju9fOho7usu8am19IgBu2DsME2Pldv5NBdNRHgcv htGmlHUKemtXGVikIMYS46KcnNcnvHe/SRjO2uQgZpOSq6QAlm1raCelQI7s+ah0hxIz wEUnrypKHiDeALq9zXEiLzLnpeLnlMsBZDxIUxPKroTCcdJxV9NGO72VLP7TLw5oAbdP zKDA== MIME-Version: 1.0 In-Reply-To: <50F2B6B0.3080309@tim.thechases.com> References: <50F2B6B0.3080309@tim.thechases.com> From: Boris FELD Date: Sun, 13 Jan 2013 14:48:50 +0100 Subject: Re: For Loop in List To: Tim Chase Content-Type: text/plain; charset=UTF-8 Cc: Python mailing list , subhabangalore@gmail.com 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358084954 news.xs4all.nl 6868 [2001:888:2000:d::a6]:34833 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36734 2013/1/13 Tim Chase : > On 01/13/13 06:45, subhabangalore@gmail.com wrote: > >>>> SIZE = 3 >>>> for i in range(len(list1)//SICE): > ... print list1[i*SIZE:i*SIZE+SIZE] > ... > [1, 2, 3] > [4, 5, 6] > [7, 8, 9] > [10, 11, 12] > A little shorter and simpler version: >>> x = x[1:] >>> for i in range(0,len(x),SIZE): ... print x[i: i+SIZE] ... [1, 2, 3] [4, 5, 6] [7, 8, 9] [10, 11, 12] Hope it helps > Hope this helps, > > -tkc