<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 08/06/2011 10:07 AM, smith jack wrote:
<blockquote
cite="mid:CAN1Fwxcdtt0u_TT=civMes1hA2qvfkH2YckES7B7qRE++DXzJQ@mail.gmail.com"
type="cite">
<pre wrap="">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]
i do not want to use loop, any methods to make this done?
</pre>
</blockquote>
<br>
List comprehension:<br>
<blockquote>L1 = [item[0] for item in L]<br>
L2 = [item[1] for item in L]<br>
</blockquote>
which *is* still a loop. (You are going to have to write *really*
arcane code to have no loop.)<br>
<br>
Gary Herron<br>
<br>
<blockquote><br>
</blockquote>
</body>
</html>