<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><div><br>Hi,</div>
<div> </div>
<div>I am multipliying two lists so that each of list As elements get multiplied to the corresponding list Bs. Then I am summing the product.</div>
<div> </div>
<div>For example, A= [1, 2, 3] and B=[2, 2, 2] so that I get [2, 4, 6] after multiplication and then sum it to get 12. I can do it using map like this:</div>
<div> </div>
<div>sum(map(lambda i,j:i*j, A, B))</div>
<div> </div>
<div>But map is being dropped out in python 3? or has it already been dropped?</div></div></blockquote><div>It appears to still work in 3.1.1. I don&#39;t know if it is going to be dropped.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div dir="ltr"><div> And I have heard Guido say that list comprehension do a better job than map so how would we do this with list comps?</div></div></blockquote>This should be equivalent.<br><br>Python 3.1.1+ (r311:74480, Nov  2 2009, 15:45:00) <br>

[GCC 4.4.1] on linux2<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>&gt;&gt;&gt; A=[1,2,3]<br>&gt;&gt;&gt; B=[2,2,2]<br>&gt;&gt;&gt; [i*j for i,j in zip(A,B)]<br>

[2, 4, 6]<br>&gt;&gt;&gt; sum([i*j for i,j in zip(A,B)])<br>12<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">
<div> </div>
<div>Thanks,</div>
<div>Ali</div></div>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<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>