Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10979
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <z@etiol.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.038 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.00; 'subject:two': 0.07; 'tuple': 0.09; 'elements,': 0.16; 'l1,': 0.16; 'subject:list': 0.18; '>>>': 0.18; 'this?': 0.21; 'header:In-Reply-To:1': 0.22; 'separate': 0.28; 'lists': 0.28; 'message-id:@mail.gmail.com': 0.29; 'url:library': 0.31; 'subject:?': 0.31; 'list': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; '...': 0.34; 'url:python': 0.36; 'subject:lists': 0.36; 'two': 0.37; 'received:google.com': 0.38; 'url:org': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'url:functions': 0.84 |
| MIME-Version | 1.0 |
| Sender | z@etiol.net |
| X-Originating-IP | [190.52.51.219] |
| In-Reply-To | <CANaSqUc9qsKmg4n11GLC6bWfiFXWL80uzmxECuk=ZgR1D77V1Q@mail.gmail.com> |
| References | <CAN1Fwxcdtt0u_TT=civMes1hA2qvfkH2YckES7B7qRE++DXzJQ@mail.gmail.com> <CANaSqUc9qsKmg4n11GLC6bWfiFXWL80uzmxECuk=ZgR1D77V1Q@mail.gmail.com> |
| Date | Sat, 6 Aug 2011 13:30:49 -0400 |
| X-Google-Sender-Auth | L7Y6EEm1BBpRtG7if6nQCSGoWRI |
| Subject | Fwd: how to separate a list into two lists? |
| From | Zero Piraeus <schesis@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.1988.1312651853.1164.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1312651853 news.xs4all.nl 23956 [2001:888:2000:d::a6]:53085 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10979 |
Show key headers only | View raw
:
> if a list L is composed with tuple consists of two elements, that is
> L = [(a1, b1), (a2, b2) ... (an, bn)]
>
> is there any simple way to divide this list into two separate lists , such that
> L1 = [a1, a2... an]
> L2=[b1,b2 ... bn]
How about this?
>>> L = [("a1", "b1"), ("a2", "b2"), ("an", "bn")]
>>> L1, L2 = zip(*L)
>>> L1
('a1', 'a2', 'an')
>>> L2
('b1', 'b2', 'bn')
http://docs.python.org/library/functions.html#zip
-[]z.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Fwd: how to separate a list into two lists? Zero Piraeus <schesis@gmail.com> - 2011-08-06 13:30 -0400
csiph-web