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


Groups > comp.lang.python > #11739

Re: pairwise combination of two lists

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: pairwise combination of two lists
References <mailman.146.1313614713.27778.python-list@python.org>
Date 2011-08-18 00:18 -0700
Message-ID <7x1uwjdw6e.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX

Show all headers | View raw


Yingjie Lin <Yingjie.Lin@mssm.edu> writes:
> li1 = ['a', 'b']
> li2 = ['1', '2']
>
> and I wish to obtain a list like this
> li3 = ['a1', 'a2', 'b1', 'b2']

from itertools import *

li3 = list(chain.from_iterable(izip(li1,li2)))

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


Thread

pairwise combination of two lists Yingjie Lin <Yingjie.Lin@mssm.edu> - 2011-08-17 16:22 -0400
  Re: pairwise combination of two lists Mel <mwilson@the-wire.com> - 2011-08-17 17:15 -0400
    Re: pairwise combination of two lists Mel <mwilson@the-wire.com> - 2011-08-17 17:18 -0400
  Re: pairwise combination of two lists Marc Christiansen <usenet@solar-empire.de> - 2011-08-17 23:43 +0200
  Re: pairwise combination of two lists Luis M. González <luismgz@gmail.com> - 2011-08-17 16:27 -0700
  Re: pairwise combination of two lists Paul Rubin <no.email@nospam.invalid> - 2011-08-18 00:18 -0700
  Re: pairwise combination of two lists Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-08-18 09:30 +0200
  Re: pairwise combination of two lists SigmundV <sigmundv@gmail.com> - 2011-08-18 14:51 -0700

csiph-web