Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10978
| From | Emile van Sebille <emile@fenx.com> |
|---|---|
| Subject | Re: how to separate a list into two lists? |
| Date | 2011-08-06 10:24 -0700 |
| References | <CAN1Fwxcdtt0u_TT=civMes1hA2qvfkH2YckES7B7qRE++DXzJQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1986.1312651348.1164.python-list@python.org> (permalink) |
On 8/6/2011 10:07 AM smith jack said...
> 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]
>
>>> L = [('a1', 'b1'), ('a2', 'b2'),('an', 'bn')]
>>> zip(*L)
[('a1', 'a2', 'an'), ('b1', 'b2', 'bn')]
Emile
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: how to separate a list into two lists? Emile van Sebille <emile@fenx.com> - 2011-08-06 10:24 -0700
Re: how to separate a list into two lists? bud <only@fleshwound.org> - 2011-08-06 18:21 +0000
Re: how to separate a list into two lists? Chris Angelico <rosuav@gmail.com> - 2011-08-06 19:35 +0100
Re: how to separate a list into two lists? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-07 10:13 +1000
csiph-web