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


Groups > comp.lang.python > #11714

pairwise combination of two lists

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <Yingjie.Lin@mssm.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.079
X-Spam-Evidence '*H*': 0.85; '*S*': 0.01; 'subject:two': 0.07; 'python': 0.08; 'users,': 0.13; 'handy': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; 'function': 0.27; 'list': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; 'thank': 0.35; 'charset:us- ascii': 0.36; 'subject:lists': 0.36; 'but': 0.37; 'especially': 0.37; 'two': 0.37; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'you.': 0.62; 'wish': 0.69; 'lists:': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=mssm.edu; h=date : from : subject : to : message-id : mime-version : content-type : content-transfer-encoding; s=mail; bh=8JjY+uyRVwwc6R5QzSwQ0vShvkCtS4yCI3NHR3IE/Zg=; b=qQ+OvTAB2I1xpiwlsQMRVQs+cp7jrzL9o5yytiU9YeGrZI2oUejDnEe8T975wFAD5kao 8Xb7ql3p0SVP4wwq26p8KIIzApudSlASLJrwdGvJvZcXTvSIQP88YnGUNQe9K8Y698nu /2oXKyV1hhD4Vh9OLRu5L/JMkExrwnzWoTyqmDjug9PwCYI38IsYtaoFaBq2S9pahPIo x+FcxLDaBGmAnSCNPq5j8wRwhm8s40sBsSHLanjvv4/660mdjK/7y/TLdAFtbvu02r35 /1wGXLhPnmqPnJXWmyeWiFFASZDMNXxOes8uuZ3zG4XEb/03++i1zsRmy6TIhso3+1kd 9Q==
Date Wed, 17 Aug 2011 16:22:48 -0400
From Yingjie Lin <Yingjie.Lin@mssm.edu>
Subject pairwise combination of two lists
To python-list@python.org
MIME-version 1.0
X-Mailer Apple Mail (2.1084)
Content-type text/plain; charset=us-ascii
Content-transfer-encoding 7BIT
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:5.4.6813, 1.0.211, 0.0.0000 definitions=2011-08-17_08:2011-08-17, 2011-08-17, 1970-01-01 signatures=0
X-Proofpoint-Spam-Details rule=notspam policy=default score=9 spamscore=9 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1012030000 definitions=main-1108170237
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.146.1313614713.27778.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313614713 news.xs4all.nl 23841 [2001:888:2000:d::a6]:55977
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11714

Show key headers only | 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