Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36734

Re: For Loop in List

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 <lothiraldan@gmail.com>
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 <f14eb990-b951-4e57-bc70-4a85f837aa51@googlegroups.com> <50F2B6B0.3080309@tim.thechases.com>
From Boris FELD <lothiraldan@gmail.com>
Date Sun, 13 Jan 2013 14:48:50 +0100
Subject Re: For Loop in List
To Tim Chase <python.list@tim.thechases.com>
Content-Type text/plain; charset=UTF-8
Cc Python mailing list <python-list@python.org>, 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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.467.1358084954.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


2013/1/13 Tim Chase <python.list@tim.thechases.com>:
> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

For Loop in List subhabangalore@gmail.com - 2013-01-13 04:45 -0800
  Re: For Loop in List Dave Angel <d@davea.name> - 2013-01-13 08:20 -0500
  Re: For Loop in List Tim Chase <python.list@tim.thechases.com> - 2013-01-13 07:29 -0600
  Re: For Loop in List Boris FELD <lothiraldan@gmail.com> - 2013-01-13 14:48 +0100
  Re: For Loop in List Tim Chase <python.list@tim.thechases.com> - 2013-01-13 08:07 -0600
  Re: For Loop in List Mitya Sirenef <msirenef@lightbird.net> - 2013-01-13 12:41 -0500

csiph-web