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


Groups > comp.lang.python > #11714

pairwise combination of two lists

Date 2011-08-17 16:22 -0400
From Yingjie Lin <Yingjie.Lin@mssm.edu>
Subject pairwise combination of two lists
Newsgroups comp.lang.python
Message-ID <mailman.146.1313614713.27778.python-list@python.org> (permalink)

Show all headers | View raw


Hi Python users,

I have two lists: 

li1 = ['a', 'b']
li2 = ['1', '2']

and I wish to obtain a list like this

li3 = ['a1', 'a2', 'b1', 'b2']

Is there a handy and efficient function to do this, especially when li1 and li2 are long lists.
I found zip() but it only gives [('a', '1'), ('b', '2')],  not exactly what I am looking for.

Thank you.


- Yingjie






Back to comp.lang.python | Previous | NextNext 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