Hi,<br><br>a = [4,3,2,6,7,9]<br>b = [8,6,3,3,2,7]<br><br>You can turn this into a list of two element tuples with zip():<br>&gt;&gt;&gt; zip(a,b)<br>[ (4,8),(3,6,),(2,3),(6,3),(7,2),(9,7) ]<br><br>Now you can loop through that and compare both elements, for instance I believe this list comprehension is what you&#39;re looking for:
<br><br>[ t[0] &lt; t[1] for t in zip(a,b) ]<br><br>but of course we can write that more elegantly with<br><br>[ i&lt;j for i,j in zip(a,b) ]<br><br>Gives a list of booleans.<br><br>Remco Gerlich<br><br><div class="gmail_quote">
On Dec 25, 2007 4:52 PM, sith . &lt;<a href="mailto:sith618@yahoo.com">sith618@yahoo.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>sith . wrote:<br>&gt; Hi,<br>&gt; I&#39;ve read the posts on comparing 2 lists and couldn&#39;t find the answer to<br>&gt; my question.<br>&gt; I have 2 lists<br>&gt; a = [4,3,2,6,7,9]<br>&gt; b = [8,6,3,3,2,7]<br>&gt; How can I determine if the elements in a are larger or smaller than the
<br>&gt; elements in b.<br>&gt;&nbsp; <br>&gt; for i in a:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; for u in b:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i &gt; u<br>&gt; does not return the result I seek.<br>&gt; <br>&gt; In this example, 4 from a is compared to 8,6,3,3,2,7 then 3 from a is
<br>&gt; compared to all the elements in b.<br>&gt; I&#39;d like<br>&gt; 4 to 8,<br>&gt; 3 to 6,<br>&gt; 2 to 3 and so on; like 2 columns in excel, the third column would be a<br>&gt; new list of boolean values.<br>&gt; Can someone help please?&nbsp; Thank you.
<br>&gt; </div>  <div>all(all(i&gt;j for j in b) for i in a)</div>  <div>HTH</div>  <div>&nbsp;</div>  <div>&nbsp;</div>  <div>Hi,<br>Thanks for
 your reply.&nbsp; This is what I get:</div>  <div>&gt;&gt;&gt; a = [4,3,2,6,7,9]</div>  <div>&gt;&gt;&gt; b = [8,6,3,3,2,7]</div>  <div>&gt;&gt;&gt; all(all(i&gt;j for j in b) for i in a)<br>&gt;&gt;&gt; all(all(i&gt;j for j in b) for i in a)
</div>  <div>False</div>  <div>How do I make it loop through the whole list?</div><div class="WgoR0d"><p> 

      </p><hr size="1">Never miss a thing.  <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs" target="_blank"> Make Yahoo your homepage.</a>

</div><br>_______________________________________________<br>Tutor maillist &nbsp;- &nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor
</a><br><br></blockquote></div><br>