Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43332
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <Thomas.Goebel@ohm-hochschule.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | UNSURE 0.244 |
| X-Spam-Level | ** |
| X-Spam-Evidence | '*H*': 0.58; '*S*': 0.07; 'list...': 0.07; 'subject:create': 0.09; 'received:141': 0.14; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'subject:lists': 0.35; 'list': 0.37; 'list.': 0.37; 'lists.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'range': 0.61; 'header:Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'name': 0.63; 'header:Reply-To:1': 0.67; 'containing': 0.69; 'reply-to:no real name:2**0': 0.71; 'lists:': 0.91 |
| Date | Wed, 10 Apr 2013 15:55:54 +0200 |
| From | Thomas Goebel <Thomas.Goebel@ohm-hochschule.de> |
| Organization | Technische Hochschule Nuernberg |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: use a loop to create lists |
| References | <4c47da9e-c632-4855-98a7-0506d8013046@googlegroups.com> |
| In-Reply-To | <4c47da9e-c632-4855-98a7-0506d8013046@googlegroups.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Mailman-Approved-At | Thu, 11 Apr 2013 09:34:47 +0200 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | Thomas.Goebel@ohm-hochschule.de |
| 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.446.1365665688.3114.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1365665688 news.xs4all.nl 2600 [2001:888:2000:d::a6]:44113 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43332 |
Show key headers only | View raw
* On 10/04/2013 10:40, martaamunar@gmail.com wrote:
> Hi!
>
> I would like to create a list containing lists. I need each list to
> have a differente name and i would like to use a loop to name the
> list.
> [...]
> global_list=[]
> for i in range (20):
> ("list_"+i)=[] #These would be the name of the list...
> global_list.append("list_"+i)
You can use a dictionary instead of a list of lists:
global_list = {'_'.join(['list', str(i)]):[] for i in range(20)}
global_list_1 = global_list['list_0']
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
use a loop to create lists martaamunar@gmail.com - 2013-04-10 01:40 -0700 Re: use a loop to create lists Chris Angelico <rosuav@gmail.com> - 2013-04-10 18:52 +1000 Re: use a loop to create lists Dave Angel <davea@davea.name> - 2013-04-10 08:36 -0400 Re: use a loop to create lists rusi <rustompmody@gmail.com> - 2013-04-10 08:31 -0700 Re: use a loop to create lists Thomas Goebel <Thomas.Goebel@ohm-hochschule.de> - 2013-04-10 15:55 +0200 Fwd: use a loop to create lists Franz Kelnreiter <kelnreiter@gmail.com> - 2013-04-11 14:11 +0200 Re: use a loop to create lists Thomas Goebel <Thomas.Goebel@ohm-hochschule.de> - 2013-04-11 14:57 +0200 Re: use a loop to create lists Chris Angelico <rosuav@gmail.com> - 2013-04-11 23:22 +1000 Re: Fwd: use a loop to create lists Thomas Goebel <Thomas.Goebel@ohm-hochschule.de> - 2013-04-11 15:43 +0200 Re: use a loop to create lists Franz Kelnreiter <kelnreiter@gmail.com> - 2013-04-11 16:11 +0200 Re: use a loop to create lists Thomas Goebel <Thomas.Goebel@ohm-hochschule.de> - 2013-04-11 16:33 +0200 Re: Fwd: use a loop to create lists Franz Kelnreiter <kelnreiter@gmail.com> - 2013-04-11 16:33 +0200 Re: use a loop to create lists Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-04-11 18:17 -0400
csiph-web